У меня возникла эта проблема, так как я обновился до 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: класс { функ photoSelectViewControllerSelectedImage (изображение: пользовательский интерфейс) Изображение) }
попробовать дать ему ширину –
по умолчанию Не могли бы вы показать, как вы добавили предупреждение? – GoodSp33d