Customizing your list to include photos is one of those finishing touches that adds good polish to your application. Let's now include an image selector for our Companies during the creation process. You're free to use whatever design you like but I prefer having image selections at the top of the screen.

Comments (11)
edward
5 years ago
Hi Brian. When updating the companyImageView, do we not need to do it on the main thread?
Brian Voong
5 years ago
edward
5 years ago
argh ok - because we are on the main thread already we don't need to call it on main thread to satisfy the rule that all ui changes need to be done on the main thread. so can you assume that unless you are doing something on the background thread - like a call to a server to fetch an image, you will be on the main thread and don't need to worry about updating on the main thread including when reloading a tableView or collectionView? I have always been using DispatchQueue().main.async for reloading data, changing images etc which I gather now is often redundant extra code right?
Esat Kemal Ekren
5 years ago
Hi Brain. Should we get permission from user to access photos? Is that cause problem for us when we submit the app store ?
Esat Kemal Ekren
5 years ago
In the next lesson we fix that. Thank you
Brian Voong
5 years ago
Esat Kemal Ekren
5 years ago
It's weird i installed app on my real device even i had saved plist file with photo privacy i didn't see the allow message board in my device
Brian Voong
5 years ago
Share App
5 years ago
Is it related to this update from WWDC 2017? "you can use UIImagePickerController to ask the user to choose a single photo without getting access to the whole library" "you can ask for write-only support to only save photos (NSPhotoLibraryAddUsageDescription)" From: https://mackuba.eu/2017/07/05/new-stuff-from-wwdc-2017/
Stryfe
5 years ago
Noticed an error when selecting a photo and saving. Tried googling error, others reporting same message, but none of the suggestions have cleared the error IntermediateTraining[61057:21807127] [discovery] errors encountered while discovering extensions: Error Domain=PlugInKit Code=13 "query cancelled" UserInfo={NSLocalizedDescription=query cancelled}
jamakaca
4 years ago
A couple of changes from what is in the video that may be useful for those using Xcode 10. For the default image use - let imageView = UIImageView(image: UIImage(named: "select_photo_empty")) For the imagePickerController : didFinishPickingMediaWithInfo use - if let editedImage = info[UIImagePickerController.InfoKey.editedImage] as? UIImage { companyImageView.image = editedImage } else if let originalImage = info[UIImagePickerController.InfoKey.originalImage] as? UIImage { companyImageView.image = originalImage }
Brian Voong
4 years ago
xuhua
4 years ago
thanks!
jdhindsa
4 years ago
The image view (with the question mark image) looks squished. What am I doing wrong? Here's the code in setupUI(): private func setupUI(){ let lightBlueBackgroundView = UIView() lightBlueBackgroundView.backgroundColor = UIColor.lightBlueColor lightBlueBackgroundView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(lightBlueBackgroundView) lightBlueBackgroundView.topAnchor.constraint(equalTo: view.topAnchor).isActive = true lightBlueBackgroundView.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true lightBlueBackgroundView.rightAnchor.constraint(equalTo: view.rightAnchor).isActive = true lightBlueBackgroundView.heightAnchor.constraint(equalToConstant: 350).isActive = true view.addSubview(companyImageView) companyImageView.topAnchor.constraint(equalTo: view.topAnchor, constant: 8).isActive = true companyImageView.heightAnchor.constraint(equalToConstant: 100) companyImageView.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true companyImageView.widthAnchor.constraint(equalToConstant: 100).isActive = true view.addSubview(nameLabel) nameLabel.topAnchor.constraint(equalTo: companyImageView.bottomAnchor).isActive = true nameLabel.leftAnchor.constraint(equalTo: view.leftAnchor, constant: 16).isActive = true nameLabel.widthAnchor.constraint(equalToConstant: 100).isActive = true nameLabel.heightAnchor.constraint(equalToConstant: 50).isActive = true view.addSubview(nameTextField) nameTextField.leftAnchor.constraint(equalTo: nameLabel.rightAnchor).isActive = true nameTextField.rightAnchor.constraint(equalTo: view.rightAnchor).isActive = true nameTextField.bottomAnchor.constraint(equalTo: nameLabel.bottomAnchor).isActive = true nameTextField.topAnchor.constraint(equalTo: nameLabel.topAnchor).isActive = true // setup the date picker view.addSubview(datePicker) datePicker.topAnchor.constraint(equalTo: nameLabel.bottomAnchor).isActive = true datePicker.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true datePicker.rightAnchor.constraint(equalTo: view.rightAnchor).isActive = true datePicker.bottomAnchor.constraint(equalTo: lightBlueBackgroundView.bottomAnchor).isActive = true }
Brian Voong
4 years ago
jdhindsa
4 years ago
Worked beautifully!
Cinquain
4 years ago
Good stuff good stuff. Loving this series
Abdullah Amer II
3 years ago
Dear Brian, I have two main questions if you can help me please: 1- how to change the default ViewController? after followed. your classes I want to add another view controller before this view controller, I done it using the Main.storyborard (using the easy way). and when I change it from the AppDelegate it didn't work for me. 2- how to increase the width of the cell in the TableView? I increased the data to be displayed so I need more size. Thanks a lot
Brian Voong
3 years ago
Abdullah Amer II
3 years ago
thanks a lot sir, 1- for number 1 suggestion it didn't work, I tried to modified the code to navController.pushViewController(MainViewController(), animated: true) but still not working. 2-No 2 is successfully solved I added "cell.textLabel?.numberOfLines = 3;" to make the table cell three lines
Abdullah Amer II
3 years ago
would you mind to take a look at the code please?
Abdullah Amer II
3 years ago
Dear Brian, Regarding to your your suggestion of using navigationController.pushViewController(xController) I keep getting an error saying... Use of unresolved identifier 'navigationController'; did you mean 'UINavigationController'? Replace 'navigationController' with 'UINavigationController' what should I do
Brian Voong
3 years ago
Abdullah Amer II
3 years ago
Alright thanks a lot will do so..
Abdullah Amer II
3 years ago
Dear Mr Brian, I had did what you done in episode 16 for the navigationController, In your case you do a TableView Controller, while in my case I am using ViewController, so I did like the code below but the issue still the same, the CompanyController showing first while I want the MainViewController to show first... extension MainViewController { override func showDetailViewController(_ vc: UIViewController, sender: Any?) { let mainViewController = MainViewController() navigationController?.pushViewController(mainViewController, animated: true) } }
Abdullah Amer II
3 years ago
Sir, my issue is that I want another viewController to show up first, by clicking on one of the buttons then the CompanyController will show, the option of navigationController is not helping... This is the only issue left in my app to be done... Can you please help?
Abdullah Amer II
3 years ago
Dear Mr Brian, I had did what you done in episode 16 for the navigationController, In your case you do a TableView Controller, while in my case I am using ViewController, so I did like the code below but the issue still the same, the CompanyController showing first while I want the MainViewController to show first then I press on button and it bring me to the CompanyController extension MainViewController { override func showDetailViewController(_ vc: UIViewController, sender: Any?) { let mainViewController = MainViewController() navigationController?.pushViewController(mainViewController, animated: true) } }
Abdullah Amer II
3 years ago
Dear Mr Brian, can I get your help please, I still waiting your reply to my previous question "Dear Mr Brian, I had did what you done in episode 16 for the navigationController, In your case you do a TableView Controller, while in my case I am using ViewController, so I did like the code below but the issue still the same, the CompanyController showing first while I want the MainViewController to show first then I press on button and it bring me to the CompanyController extension MainViewController { override func showDetailViewController(_ vc: UIViewController, sender: Any?) { let mainViewController = MainViewController() navigationController?.pushViewController(mainViewController, animated: true) } }"
Brian Voong
3 years ago
Manish Prakharan
3 years ago
good stuff good stuff,, enjoying my lockdown period
HELP & SUPPORT