swift3

Swift 3 - Open URL from JSON in Safari

主宰稳场 提交于 2019-12-13 08:57:16
问题 I currently have a mobile app that brings in a list of items from a JSON file. The JSON file also has a list of urls attached to each item. I need to open the URL in Safari when the user touches the item in the list view. override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) cell.textLabel?.text = TableData[indexPath.row] return cell } Does anyone have an idea

Change height and width of view according to scrollview scroll horizontally using auto layout

孤人 提交于 2019-12-13 08:54:25
问题 Container View hierarchy:- Container View Scrollview view left view center view right FloatingBottomView I need to change height and width constrain of FloatingBottomView according to scrollview scroll horizontally. Initial Outlet:- @IBOutlet weak var constantFloatingBottomViewWidth: NSLayoutConstraint! // 300 @IBOutlet weak var constantFloatingBottomViewHeight: NSLayoutConstraint! // 70 override func viewWillAppear(_ animated: Bool) { self.scrollView.contentOffset.x = self.view.bounds.width

Hiding status bar not working Swift 3, Xcode 8.0

☆樱花仙子☆ 提交于 2019-12-13 08:46:04
问题 Set Target/General/Deployment info to Hide status bar. Set None for Status Bar in VCs in storyboards. Added the following code to all VCs. override var prefersStatusBarHidden: Bool { return true } Briefly hides status bar but immediately reappears. 回答1: Only the prefersStatusBarHidden of the root-level view controller matters — here, the split view controller. The split view controller wants a status bar; it gets a status bar. That is all that matters. You could try subclassing

Add Progress bar to UIAlertController with showing update

纵然是瞬间 提交于 2019-12-13 08:37:54
问题 I try to add progress bar on my application. I found the question on How to add Progress bar to UIAlertController? but it didn't show how to update the progress bar. I simplify the code as below but it didn't update the progress bar (it shows only once the progress is completed). What did i over look? Thank you for your help. override func viewDidLoad() { super.viewDidLoad() var topViewController = UIApplication.shared.delegate!.window!!.rootViewController! while (topViewController

Convert String to Decimal number it remove points before zeros in Swift 4

爷,独闯天下 提交于 2019-12-13 08:31:03
问题 Please check this example let strValue = "12.00" let decimalValue = Decimal(string: strValue) // 12 it always returns 12 not 12.00 I also try with NSNumber , Float , and Double but it always remove zeros. Can you please help me with this thanks in advance 回答1: Like martin said. 12 and 12.00 is the same number. It doesn't mathematical matter how many 0 are behind the comma. While a number stays the same, the representation is a different topic. String(format: "%.6f", 12) will give 12.000000 as

How to check same values for the multiple keys in array of json Object?

对着背影说爱祢 提交于 2019-12-13 08:29:46
问题 I am working on calendar using Swift3 . I know it's possible to set same values for different keys. I have this NSArray called Dictionary of JSON objects: if parsedData["status"] as! Int == 200 { if let Streams = parsedData["data"] as! [AnyObject]? { for Stream in Streams { print(Stream) } Stream result: { "-" = 4; 1 = X; 10 = H; 11 = X; 12 = X; 13 = X; 14 = X; 15 = X; 16 = X; 17 = H; 18 = X; 19 = X; 2 = X; 20 = X; 21 = X; 22 = X; 23 = L; 24 = H; 25 = X; 26 = L; 27 = "-"; 28 = "-"; 29 = "-";

How to perform segue to Different Controllers in UICollectionVIew

跟風遠走 提交于 2019-12-13 08:25:55
问题 I want to segue to different controllers based on selection in UICollectionView : override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { if indexPath.item == 0 && indexPath.section == 0 { print ("Item 0 and section 0 selected") Perform Segue to Controller1 } else if (indexPath.item == 1 && indexPath.section == 0 ){ ----> Perform Segue to Controller 2 print ("Item 1 and section 0 selected") } else { print("Not selected ") } } Based on selection

How to set Flow layout for this scenario using UICollectionview?

夙愿已清 提交于 2019-12-13 07:29:40
问题 I Wanted to design the UICollectionview both portrait and landscape mode.Here i am using UICollectionViewFlowLayout I have entered my view controller code import UIKit class ViewController: UIViewController,UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout { @IBOutlet var collectionObject: UICollectionView! var isOrientation = true let layout: UICollectionViewFlowLayout = UICollectionViewFlowLayout() override func viewDidLoad() { super.viewDidLoad() // Do

Amazon S3 Cognito - Upload image from image picker - Swift 3

落花浮王杯 提交于 2019-12-13 07:26:56
问题 I have done static image upload to AWS server successfully. When i combine it with imagepicker, I am facing a wierd issue due to which same image is being uploaded to AWS even though I pick and name them differently. The code is as follows: internal func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) { let image = info[UIImagePickerControllerOriginalImage] as! UIImage var imageUrl = info[UIImagePickerControllerReferenceURL] as?

Previous segue repeats on time on different button

拟墨画扇 提交于 2019-12-13 07:25:37
问题 I'll try to explain you my problem at my best.I'm trying to build a kind of schedule using a circular animation. I have 2 views: the first one contains 6 buttons with the titles from MONDAY to SATURDAY. When the user clicks on a button it will present modally the second view, which contains only one button with no title; this second view will take the backgroundColor and the title of the button from the previous VC: ScheduleDaysViewController. In the second view ,if the user clicks on the