问题描述
这已经困扰了我一段时间了.我在 UITabBarController
中有一个 UISplitViewController
.主视图是一个 TableView.当我点击一个单元格时,我会调出一个非常基本的视图控制器,其中只有一个 UIButton
居中.这是视图控制器的代码:
This has been stumping me for a while now. I have a UISplitViewController
inside a UITabBarController
. The master view is a TableView. When I click on a cell, I bring up a very basic view controller with just a UIButton
centered. Here is the code for the 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)
}
}
如果我单击取消或选择和图像,选择器控制器会正确关闭.当我点击后退按钮返回到 TableView 时,问题出现了,我收到:
If I click cancel or select and image, the picker controller dismisses properly. The problem comes when I click on the back button to return to the TableView, I receive:
Unbalanced calls to begin/end appearance transitions for <TestViewController: 0x7fb882a72380>.
TestViewController
非常基础,为什么会发生这种情况?
The TestViewController
is very basic, so why would this be happening?
推荐答案
如果您在上一个事务(动画)正在进行时尝试推送新的视图控制器,则会出现此问题.因此,请检查您的代码流程并进行适当的更改.检查您的关闭和呈现视图动画.您可以使用属性 setAnimation 来是/否"解决此问题
This issue occurs if you trying to push new view controller while previous transaction (animation) in progress. So please check your code flow and make the appropriate changes. Check your dismiss and present view animations. You can use property setAnimation to 'YES/NO'resolve this
设置动画:NO,可能会解决您的问题
Set animated:NO, may be solve your problem
这篇关于Swift Unbalanced 调用开始/结束外观过渡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!