我開始有這個問題,因爲我更新到Xcode 8我不知道它是否可以依賴於一個Xcode錯誤。UIAlertView問題
我有這個問題:this happens when I add this view to a tab bar。
它應該是這樣的if you do not tie it to anything it remains unchanged。
的問題,是不是我的代碼 我下面添加
import UIKit
類PhotoSelectViewController:UIViewController中,UINavigationControllerDelegate,UIImagePickerControllerDelegate {
@IBOutlet weak var imageView: UIImageView!
@IBOutlet weak var selectImageButton: UIButton!
weak var delegate: PhotoSelectViewControllerDelegate?
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func selectImageTapped(_ sender: AnyObject) {
let imagePicker = UIImagePickerController()
imagePicker.delegate = self
let actionSheet = UIAlertController(title: "Choose image source", message: nil, preferredStyle: .actionSheet)
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil)
let photoLibraryAction = UIAlertAction(title: "Photo Library", style: .default) { (_) in
imagePicker.sourceType = .photoLibrary
self.present(imagePicker, animated: true, completion: nil)
}
let cameraAction = UIAlertAction(title: "Camera", style: .default) { (_) in
imagePicker.sourceType = .camera
self.present(imagePicker, animated: true, completion: nil)
}
actionSheet.addAction(cancelAction)
if UIImagePickerController.isSourceTypeAvailable(.photoLibrary) {
actionSheet.addAction(photoLibraryAction)
}
if UIImagePickerController.isSourceTypeAvailable(.camera) {
actionSheet.addAction(cameraAction)
}
self.present(actionSheet, animated: true, completion: nil)
selectImageButton.setTitle("", for: .normal)
}
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
if let image = info[UIImagePickerControllerOriginalImage] as? UIImage {
imageView.image = image
delegate?.photoSelectViewControllerSelectedImage(image: image)
}
dismiss(animated: true, completion: nil)
}
}
協議PhotoSelectViewControllerDelegate:類{ FUNC photoSelectViewControllerSelectedImage (圖片:用戶界面圖片) }
嘗試給它一個默認的寬度 –
能否請你告訴你如何添加警報? – GoodSp33d