Adding a Video file from library to application? - ios

I am currently working on uploading Photos and videos to my app. So far I got the photo uploading done, but when I access my library on my iPad, I can't see my videos or choose them. Anyone who knows how I can do this?
This is my code so far:
Class SixthViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate
{
#IBOutlet weak var logUd: UIButton!
#IBOutlet weak var myImageView: UIImageView!
#IBOutlet weak var vælgFiler: UIButton!
var SelectedAssets = [PHAsset]()
var PhotoArray = [UIImage]()
#IBOutlet weak var upload: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
logUd.backgroundColor = UIColor.white
logUd.layer.cornerRadius = 7
logUd.setTitleColor(UIColor.black, for: .normal)
vælgFiler.backgroundColor = UIColor.white
vælgFiler.layer.cornerRadius = 7
vælgFiler.setTitleColor(UIColor.black, for: .normal)
upload.backgroundColor = UIColor.white
upload.layer.cornerRadius = 7
upload.setTitleColor(UIColor.black, for: .normal)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
#IBAction func logUd(_ sender: Any) {
dismiss(animated: true, completion: nil)
}
#IBAction func upload(_ sender: Any) {
//myImageUploadRequest()
}
#IBAction func vælgFiler(_ sender: Any) {
let vc = BSImagePickerViewController()
self.bs_presentImagePickerController(vc, animated: true,
select: { (assets: PHAsset) -> Void in
},deselect: { (asset: PHAsset) -> Void in
},cancel: {(assets: [PHAsset]) -> Void in
}, finish: {(assets: [PHAsset]) -> Void in
for i in 0..<assets.count{
self.SelectedAssets.append(assets[i])
}
self.convertAssetToImages()
}, completion: nil)
}
func convertAssetToImages() -> Void {
if SelectedAssets.count != 0{
for i in 0..<SelectedAssets.count{
let manager = PHImageManager.default()
let option = PHImageRequestOptions()
var thumbnail = UIImage()
option.isSynchronous = true
manager.requestImage(for: SelectedAssets[i], targetSize: CGSize(width: 200, height: 200), contentMode: .aspectFill, options: option, resultHandler: {(result, info)->Void in thumbnail = result!
})
let data = UIImageJPEGRepresentation(thumbnail, 0.7)
let newImage = UIImage(data: data!)
self.PhotoArray.append(newImage! as UIImage)
}
self.myImageView.animationImages = self.PhotoArray
self.myImageView.animationDuration = 10.0
self.myImageView.startAnimating()
}
print("complete photo array \(self.PhotoArray)")
}

If you would want BSImagePicker to be able to show videos as well as photos you will have to change the source of the library.
There is a file called PhotosViewController that displays the grid of photos. Inside is initializePhotosDataSource method that filters out all videos and displays only photos with:
fetchOptions.predicate = NSPredicate(format: "mediaType = %d", PHAssetMediaType.image.rawValue)
if you were to delete this predicate from fetchOptions the library will (and I have tested this) show videos along with photos...

Related

I get "boringssl" error when uploading image to Firebase for iOS

I'm simply trying to upload an image but I'm getting this error "[boringssl] boringssl_metrics_log_metric_block_invoke(153) Failed to log metrics
Optional("User does not have permission to access 'here was the link to the folder.' ")"
My goal is to upload a photo and access it later from another page, but now I'm getting this error.
edit: Later I realized that I am getting some of the same error while signing up "[boringssl] boringssl_metrics_log_metric_block_invoke(153)".
The entered user can register and appears in the Firebase interface, but the above error is displayed on the console.
import UIKit
import Firebase
class UploadViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
#IBOutlet weak var imageView: UIImageView!
#IBOutlet weak var commentText: UITextField!
#IBOutlet weak var uploadVar: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
imageView.isUserInteractionEnabled = true
let gestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(chooseImage))
imageView.addGestureRecognizer(gestureRecognizer)
}
#IBAction func UploadClicked(_ sender: Any) {
let storage = Storage.storage()
let storageReferance = storage.reference()
let mediaFolder = storageReferance.child("media")
if let data = imageView.image?.jpegData(compressionQuality: 0.5) {
let imageReferance = mediaFolder.child("image.jpg")
imageReferance.putData(data, metadata: nil) { metaData, error in
if error != nil {
print(error?.localizedDescription)
} else {
imageReferance.downloadURL { url, error in
if error == nil {
let imageURL = url?.absoluteString
print(imageURL)
}
}
}
}
}
}
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
imageView.image = info[.originalImage] as? UIImage
self.dismiss(animated: true, completion: nil)
}
#objc func chooseImage() {
let pickerController = UIImagePickerController()
pickerController.delegate = self
pickerController.sourceType = .photoLibrary
present(pickerController, animated: true, completion: nil)
}
}

How to select Three images with three buttons in Swift

On my screen I need to add three images for that I have three separate buttons
code: here EasyImagePicker is my custom imagepicker.. but with my below code if I select any one image from imagepicker then it's adding in all three images
class EditProfileImagesVC: UIViewController {
private var imagePicker : EasyImagePicker?
private var imagePicker1 : EasyImagePicker?
private var imagePicker2 : EasyImagePicker?
#IBOutlet weak var profilePicImage: UIImageView!
#IBOutlet weak var leftProfilePicImg: UIImageView!
#IBOutlet weak var rightProfilePicImg: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
imagePicker = EasyImagePicker(presentationController: self, delegate: self)
imagePicker1 = EasyImagePicker(presentationController: self, delegate: self)
imagePicker2 = EasyImagePicker(presentationController: self, delegate: self)
}
#IBAction func profilePicBtn(_ sender: UIButton) {
imagePicker?.present(from: sender, mediaType: .images, onViewController: self)
}
#IBAction func leftProfileBtn(_ sender: UIButton) {
imagePicker1?.present(from: sender, mediaType: .images, onViewController: self)
}
#IBAction func rightProfileBtn(_ sender: UIButton) {
imagePicker2?.present(from: sender, mediaType: .images, onViewController: self)
}
}
extension EditProfileImagesVC : EasyImagePickerDelegate{
func didSelect(image: UIImage?, video: URL?, fileName: String?) {
if let img = image{
profilePicImage.image = img
}
if let img1 = image{
leftProfilePicImg.image = img1
}
if let img2 = image{
rightProfilePicImg.image = img2
}
}
}
how to select three different images for three images using imagepicker.. please do guide me
The reason is there is no thing here that can differentiate which button is clicked , hence result set to all imageviews
func didSelect(image: UIImage?, video: URL?, fileName: String?) {
if let img = image{
profilePicImage.image = img
}
if let img1 = image{
leftProfilePicImg.image = img1
}
if let img2 = image{
rightProfilePicImg.image = img2
}
}
You need
enum ImageChooser {
case profile,left,right
}
class EditProfileImagesVC: UIViewController {
private var imagePicker : EasyImagePicker?
#IBOutlet weak var profilePicImage: UIImageView!
#IBOutlet weak var leftProfilePicImg: UIImageView!
#IBOutlet weak var rightProfilePicImg: UIImageView!
var chooser:ImageChooser = .profile
override func viewDidLoad() {
super.viewDidLoad()
imagePicker = EasyImagePicker(presentationController: self, delegate: self)
}
#IBAction func profilePicBtn(_ sender: UIButton) {
chooser = .profile
imagePicker?.present(from: sender, mediaType: .images, onViewController: self)
}
#IBAction func leftProfileBtn(_ sender: UIButton) {
chooser = .left
imagePicker1?.present(from: sender, mediaType: .images, onViewController: self)
}
#IBAction func rightProfileBtn(_ sender: UIButton) {
chooser = .right
imagePicker2?.present(from: sender, mediaType: .images, onViewController: self)
}
}
extension EditProfileImagesVC : EasyImagePickerDelegate{
func didSelect(image: UIImage?, video: URL?, fileName: String?) {
if let img = image {
if chooser == .profile {
profilePicImage.image = img
}
else
if chooser == .left {
leftProfilePicImg.image = img
}
else
if chooser == .right {
rightProfilePicImg.image = img
}
}
}
}
Add picker reference to func didSelect(image: UIImage?, video: URL?, fileName: String?)
This way func didSelect(picker: EaseImagePicker, image: UIImage?, video: URL?, fileName: String?)
From picker call it with the reference to self
didSelect(picker: self, image: selectedImage, video: nil, fileName: nil)
func didSelect(picker: EaseImagePicker, image: UIImage?, video: URL?, fileName: String?) {
if let img = image{
switch picker {
case imagePicker:
profilePicImage.image = img
case imagePicker1:
leftProfilePicImg.image = img
case imagePicker2:
rightProfilePicImg.image = img
default:
break
}
}
}

Getting error `Do you want to add protocol stubs? [duplicate]

This question already has answers here:
Xcode 8 says "Do you want to add a stub?" How do I answer?
(3 answers)
Closed 4 years ago.
I added the ImageView Protocol. What can be done to remove the error
Do you want to add protocol stubs?
CardsViewController
import UIKit
protocol ImageViewProtocol{
func sendImageToViewController(theImage: UIImage)
}
class CardsViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate, ImageViewProtocol {
#IBOutlet weak var textField: UITextField!
#IBOutlet weak var nameTextField: UITextField!
#IBOutlet weak var locationTextField: UITextField!
#IBOutlet weak var imageView: UIImageView!
#IBAction func goToViewController2Action(_ sender: Any)
{
let viewcontroller2 = storyboard?.instantiateViewController(withIdentifier: "viewController2") as! ViewController2
viewcontroller2.delegate = self
self.navigationController?.pushViewController(viewcontroller2, animated: true)
}
func chooseImagePickerAction(source: UIImagePickerController.SourceType) {
if UIImagePickerController.isSourceTypeAvailable(source) {
let imagePicker = UIImagePickerController()
imagePicker.delegate = self
imagePicker.allowsEditing = true
imagePicker.sourceType = source
self.present(imagePicker, animated: true, completion: nil)
}
}
#IBAction func saveButtonPressed(_ sender: UIBarButtonItem) {
if nameTextField.text == "" || locationTextField.text == "" || textField.text == "" {
print("Not all fields are filled")
} else {
if let context = (UIApplication.shared.delegate as? AppDelegate)?.coreDataStack.persistentContainer.viewContext {
let card = Card(context: context)
card.name = nameTextField.text
card.location = locationTextField.text
card.number = textField.text
if let image = imageView.image {
card.image = image.pngData()
}
do {
try context.save()
print("Cохранение удалось!")
} catch let error as NSError {
print("Не удалось сохранить данные \(error), \(error.userInfo)")
}
}
performSegue(withIdentifier: "unwindSegueFromNewCard", sender: self)
}
}
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
imageView.image = info[UIImagePickerController.InfoKey.editedImage] as? UIImage
imageView.contentMode = .scaleAspectFill
imageView.clipsToBounds = true
dismiss(animated: true, completion: nil)
}
}
ViewController2
import UIKit
class ViewController2: UIViewController {
var filter : CIFilter!
var delegate: ImageViewProtocol!
#IBOutlet weak var select: UISegmentedControl!
#IBOutlet weak var textField: UITextField!
#IBOutlet weak var barcodeImageView: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
barcodeImageView.image = UIImage(named: "photo")
}
#IBAction func saveButtonAction(_ sender: Any) {
if textField.text == "" {
print("Not all fields are filled")
} else {
delegate.sendImageToViewController(theImage: barcodeImageView.image!)
self.navigationController?.popViewController(animated: true)
}
performSegue(withIdentifier: "unwindSegueFromViewController", sender: sender)
}
#IBAction func tappedEnter(_ sender: Any) {
if textField.text?.isEmpty ?? true {
return
} else {
if let texttxt = textField.text {
let data = texttxt.data(using: .ascii, allowLossyConversion: false)
if select.selectedSegmentIndex == 0
{
filter = CIFilter(name: "CICode128BarcodeGenerator")
} else {
filter = CIFilter(name: "CIQRCodeGenerator")
}
filter.setValue(data, forKey: "inputMessage")
let transform = CGAffineTransform(scaleX: 5, y: 5)
let image = UIImage(ciImage: filter.outputImage!.transformed(by: transform))
barcodeImageView.image = image
}
}
}
}
This error comes because you implemented protocol (ImageViewProtcol) but you haven't add required methods of your protocol (in your case sendImageToViewController(theImage: UIImage)). All methods of your protocol are required by default. If you want to change it, you can look here.
It's the same as when you're implementing UITableViewDataSource, you also need to add required methods like number of items etc.
To fix this, add this method to your CardsViewController:
func sendImageToViewController(theImage: UIImage) {
// do something with image
}

Issues Uploading Images and posts to Firebase 5 Database

I am currently trying to upload a photo URL and post caption onto my firebase database. The photos are currently being saved on firebase storage which is fine, however I would like for it to also appear on the firebase database.
I repeatedly find myself dealing with this error "Value of type 'StorageMetadata' has no member 'downloadURL'"
I understand that in firebase 5 to get the url from storage you need to call downloadURL on storage reference, not metadata. I have tried multiple ways and examples, but it all leads to errors.screenshot of error
#IBOutlet weak var photo: UIImageView!
#IBOutlet weak var captionTextView: UITextView!
#IBOutlet weak var removeButton: UIBarButtonItem!
#IBOutlet weak var shareButton: UIButton!
var selectedImage: UIImage?
override func viewDidLoad() {
super.viewDidLoad()
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(self.handleSelectPhoto)); photo.addGestureRecognizer(tapGesture)
photo.isUserInteractionEnabled = true
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
handlePost()
}
func handlePost() {
if selectedImage != nil {
self.shareButton.isEnabled = true
self.removeButton.isEnabled = true
self.shareButton.backgroundColor = UIColor(red: 0, green: 0, blue: 0, alpha: 1)
}else{
self.shareButton.isEnabled = false
self.shareButton.backgroundColor = .lightGray
self.removeButton.isEnabled = false
}
}
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
view.endEditing(true)
}
#objc func handleSelectPhoto() {
let pickerController = UIImagePickerController()
pickerController.delegate = self
present(pickerController, animated: true, completion: nil)
}
#IBAction func shareButton_TouchUpInside(_ sender: Any) {
view.endEditing(true)
let hud = JGProgressHUD(style: .dark)
hud.textLabel.text = "Loading"
hud.show(in: self.view)
hud.dismiss(afterDelay: 3.0)
if let profileImg = self.selectedImage, let imageData = UIImageJPEGRepresentation(profileImg, 0.1) {
let photoIdString = NSUUID().uuidString
let storageRef = Storage.storage().reference(forURL: ".......").child("posts").child(photoIdString)
storageRef.putData(imageData, metadata: nil, completion: { (metadata, error) in
if error != nil {
return
}
//let photoUrl = url?.absoluteString
let photoUrl = metadata?.downloadURL()?.absoluteString
self.sendDataToDatabase(photoUrl: photoUrl!)
}
)}
}
#IBAction func remove_TouchUpInside(_ sender: Any) {
clean()
handlePost()
}
func sendDataToDatabase(photoUrl: String) {
let ref = Database.database().reference()
let postsReference = ref.child("posts")
let newPostId = postsReference.childByAutoId().key
let newPostReference = postsReference.child(newPostId)
newPostReference.setValue(["photoUrl": photoUrl, "caption": captionTextView.text!], withCompletionBlock: {
(error, ref) in
if error != nil {
ProgressHUD.showError(error!.localizedDescription)
return
}
ProgressHUD.showSuccess("Success")
self.clean()
self.tabBarController?.selectedIndex = 0 // switches user back to selected tabbar 0 = first 1 = second etc.
})
}
func clean() {
self.captionTextView.text = ""
self.photo.image = UIImage(named:"placeholder-photo")
self.selectedImage = nil
}
}
extension CameraViewController: UIImagePickerControllerDelegate,
UINavigationControllerDelegate {
func imagePickerController(_ picker: UIImagePickerController,
didFinishPickingMediaWithInfo info: [String : Any]) {
print("did finish picking media")
if let image = info["UIImagePickerControllerOriginalImage"]
as? UIImage {
selectedImage = image
photo.image = image
}
// profileImage.image = infoPhoto
dismiss(animated: true, completion: nil)
}
}
import UIKit
import ProgressHUD
import FirebaseStorage
import FirebaseDatabase
class CameraViewController: UIViewController {
#IBOutlet weak var photo: UIImageView!
#IBOutlet weak var shareButton: UIButton!
#IBOutlet weak var captionTextView: UITextView!
#IBOutlet weak var removeButton: UIBarButtonItem!
var selectedImage: UIImage?
override func viewDidLoad() {
super.viewDidLoad()
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(self.handleSelectPhoto))
photo.addGestureRecognizer(tapGesture)
photo.isUserInteractionEnabled = true
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
handlePost()
}
func handlePost(){
if selectedImage != nil {
self.shareButton.isEnabled = true
self.removeButton.isEnabled = true
self.shareButton.backgroundColor = UIColor(red: 0, green: 0, blue: 0, alpha: 1)
} else {
self.shareButton.isEnabled = false
self.removeButton.isEnabled = false
self.shareButton.backgroundColor = .lightGray
}
}
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
view.endEditing(true)
}
#objc func handleSelectPhoto(){
let pickerController = UIImagePickerController()
pickerController.delegate = self
present(pickerController, animated: true, completion: nil)
}
// Share photos to the storage database
#IBAction func shareButton_TouchUpInside(_ sender: Any) {
view.endEditing(true)
ProgressHUD.show("Please wait...", interaction: false)
if let profileImg = self.selectedImage, let photoData = profileImg.jpegData(compressionQuality: 0.1) {
let photoIdString = NSUUID().uuidString
print(photoIdString)
let storageRef = Storage.storage().reference(forURL:Config.STORAGE_ROOT_REF).child("Posts").child(photoIdString)
storageRef.putData(photoData, metadata: nil, completion: { (metadata, error) in
if error != nil {
ProgressHUD.showError(error!.localizedDescription)
return
}
let photoUrl = metadata?.downloadURL()?.absoluteString
self.sendDataToDatabase(photoUrl: photoUrl!)
})
} else {
ProgressHUD.showError("Profile image can't be empty")
}
}
#IBAction func remove_touchUpInside(_ sender: Any) {
clean()
handlePost()
}
func sendDataToDatabase(photoUrl:String){
let ref = Database.database().reference()
let postsReference = ref.child("posts")
let newPostId = postsReference.childByAutoId().key
let newPostReference = postsReference.child(newPostId)
newPostReference.setValue(["photoUrl": photoUrl, "caption": captionTextView.text!], withCompletionBlock: {
(error, ref) in
if error != nil{
ProgressHUD.showError(error!.localizedDescription)
return
}
ProgressHUD.showSuccess("Success")
self.clean()
self.tabBarController?.selectedIndex = 0
})
}
func clean(){
self.captionTextView.text = ""
self.photo.image = UIImage(named: "placeholder-img")
self.shareButton = nil
}
}
extension CameraViewController : UIImagePickerControllerDelegate, UINavigationControllerDelegate {
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
print("did Finish picking media")
if let chosenImage = info[.originalImage] as? UIImage {
selectedImage = chosenImage
photo.image = chosenImage
}
dismiss(animated: true, completion: nil)
}
}
Use Above code, it will successfully upload the image and post that to the Firebase Database

I keep getting "signal 1: SIGABRT" in swift 3 and I don't know how to get around it

I've checked all of my connections and NONE of them are broken. I've reconnected all of them and checked everything but I keep getting this error. It comes in the first line of the App Delegate and I don't know why. Here's the code.
class DetailsViewController: UIViewController, SFSafariViewControllerDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate{
let imagePicker = UIImagePickerController()
#IBOutlet weak var MITImageView: UIImageView!
#IBOutlet weak var StanfordImageView: UIImageView!
#IBOutlet weak var HarvardImageView: UIImageView!
#IBAction func MITSafariViewControllerButton(_ sender: UIButton) {
let url = NSURL(string: MITUrl)!
let svc = SFSafariViewController(url: url as URL)
present(svc, animated: true, completion: nil)
}
#IBAction func StanfordSafariViewControllerButton(_ sender: UIButton) {
let url = NSURL(string: StanfordUrl)!
let svc = SFSafariViewController(url: url as URL)
present(svc, animated: true, completion: nil)
}
#IBAction func HarvardSafariViewControllerButton(_ sender: UIButton) {
let url = NSURL(string: HarvardUrl)!
let svc = SFSafariViewController(url: url as URL)
present(svc, animated: true, completion: nil)
}
#IBAction func imageChangeButton(_ sender: UIButton) {
imagePickerClass().imagePickerControllerMIT(picker: imagePicker)
}
#IBAction func imageChangeButtonStanford(_ sender: UIButton) {
imagePickerClass().imagePickerControllerStanford(picker: imagePicker)
}
#IBAction func imageChangeButtonHarvard(_ sender: UIButton) {
imagePickerClass().imagePickerControllerHarvard(picker: imagePicker)
}
var MITUrl = "http://web.mit.edu"
var StanfordUrl = "http://stanford.edu"
var HarvardUrl = "http://www.harvard.edu"
override func viewDidLoad() {
super.viewDidLoad()
imagePicker.delegate = self
var logos = [#imageLiteral(resourceName: "MIT Logo"), #imageLiteral(resourceName: "Stanford Logo"), #imageLiteral(resourceName: "Harvard Logo")]
var pos1 = Int()
var pos2 = Int()
var pos3 = Int()
pos1 = 0
pos2 = 1
pos3 = 2
self.MITImageView.image = logos[pos1]
self.StanfordImageView.image = logos[pos2]
self.HarvardImageView.image = logos[pos3]
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
class imagePickerClass : DetailsViewController {
var pos1 = Int()
var pos2 = Int()
var pos3 = Int()
var MITImage = Int()
var StanfordImage = Int()
var HarvardImage = Int()
init (){
pos1 = 0
pos2 = 1
pos3 = 2
MITImage = 3
StanfordImage = 3
HarvardImage = 3
let code = NSCoder()
super.init(coder: code)!
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func imagePickerControllerMIT(picker: UIImagePickerController) {
self.imagePicker.sourceType = UIImagePickerControllerSourceType.photoLibrary
weak var weakSelf = self
weakSelf?.present((weakSelf?.imagePicker)!, animated: true, completion: nil)
self.imagePicker.dismiss(animated: true, completion: {
let imageSelected = [UIImagePickerControllerOriginalImage] as! UIImage
var logos = [#imageLiteral(resourceName: "MIT Logo"), #imageLiteral(resourceName: "Stanford Logo"), #imageLiteral(resourceName: "Harvard Logo"), imageSelected]
self.MITImageView.image = logos[self.MITImage]
})
}
func imagePickerControllerStanford(picker: UIImagePickerController) {
imagePicker.dismiss(animated: true, completion: {
self.imagePicker.sourceType = UIImagePickerControllerSourceType.photoLibrary
weak var weakSelf = self
weakSelf?.present((weakSelf?.imagePicker)!, animated: true, completion: {
let imageSelected = [UIImagePickerControllerOriginalImage] as! UIImage
var logos = [#imageLiteral(resourceName: "MIT Logo"), #imageLiteral(resourceName: "Stanford Logo"), #imageLiteral(resourceName: "Harvard Logo"), imageSelected]
self.MITImageView.image = logos[self.StanfordImage]
})
})
}
func imagePickerControllerHarvard(picker: UIImagePickerController) {
imagePicker.dismiss(animated: true, completion: {
self.imagePicker.sourceType = UIImagePickerControllerSourceType.photoLibrary
weak var weakSelf = self
weakSelf?.present((weakSelf?.imagePicker)!, animated: true, completion: {
let imageSelected = [UIImagePickerControllerOriginalImage] as! UIImage
var logos = [#imageLiteral(resourceName: "MIT Logo"), #imageLiteral(resourceName: "Stanford Logo"), #imageLiteral(resourceName: "Harvard Logo"), imageSelected]
self.MITImageView.image = logos[self.HarvardImage]
})
})
}
}
Heres the error
class AppDelegate: UIResponder, UIApplicationDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
If you could help me figure this out that would be great.
First want to say that I am using Xcode 7.0 and IOS 9.0. And I have also got a same problem in objective-c. I found the cause of exception simply debugging my code (Basically which line is responsible for it). And I am going to share with you. Though your question is swift related, I am just trying to help about the signal 1: SIGABRT. It's may help you.
1. First set a debug pointer of your code at any line. click show the break point navigator icon.
2. click create a break point icon.
3. click Add Exception BreakPoint.
4. Right click on the All Exception and click Edit BreakPoint.
5. select objective-c as an option of 'Exception'.
And run your application. It will take you to the corresponding line for which you get SIGABRT.

Resources