这个问题困扰了我一段时间。我在 UITabBarController
中有一个 UISplitViewController
。主视图是一个 TableView。当我点击一个单元格时,我会调出一个非常基本的 View Controller ,其中只有一个 UIButton
居中。这是 View Controller 的代码:
class TestViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
@IBOutlet weak var button: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func buttonPressed(sender: AnyObject) {
let pickerC = UIImagePickerController()
pickerC.delegate = self
pickerC.modalPresentationStyle = .Popover
pickerC.popoverPresentationController?.sourceView = button as UIView
pickerC.popoverPresentationController?.sourceRect = (button as UIView).bounds
pickerC.popoverPresentationController?.permittedArrowDirections = UIPopoverArrowDirection.Any
self.presentViewController(pickerC, animated: true, completion: nil)//4
}
func imagePickerController(picker: UIImagePickerController, didFinishPickingImage image: UIImage!, editingInfo: [NSObject : AnyObject]!) {
self.dismissViewControllerAnimated(true, completion: nil)
}
func imagePickerControllerDidCancel(picker: UIImagePickerController) {
self.dismissViewControllerAnimated(true, completion: nil)
}
}
如果我单击取消或选择图像,选择器 Controller 将正确关闭。当我单击后退按钮返回到 TableView 时出现问题,我收到:
Unbalanced calls to begin/end appearance transitions for <TestViewController: 0x7fb882a72380>.
TestViewController
非常基础,那么为什么会发生这种情况?
最佳答案
如果您在上一个事务(动画)正在进行时尝试推送新的 View Controller ,则会出现此问题。因此,请检查您的代码流并进行适当的更改。检查您的解雇和呈现 View 动画。您可以使用属性 setAnimation 来“是/否”解决此问题
设置animated:NO,可能会解决你的问题
关于ios - Swift 不平衡调用开始/结束外观转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30061153/