[英]Swift Unbalanced calls to begin/end appearance transitions for
This has been stumping me for a while now.这已经让我难住了一段时间。 I have a
UISplitViewController
inside a UITabBarController
.我在
UITabBarController
有一个UISplitViewController
。 The master view is a TableView.主视图是一个 TableView。 When I click on a cell, I bring up a very basic view controller with just a
UIButton
centered.当我单击一个单元格时,我会调出一个非常基本的视图控制器,其中只有一个
UIButton
居中。 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)
}
}
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:
当我单击后退按钮返回到 TableView 时,问题出现了,我收到:
Unbalanced calls to begin/end appearance transitions for <TestViewController: 0x7fb882a72380>.
The TestViewController
is very basic, so why would this be happening? TestViewController
是非常基础的,那么为什么会发生这种情况呢?
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
您可以使用属性 setAnimation 来“是/否”解决此问题
Set animated:NO, may be solve your problem设置动画:NO,可能会解决您的问题
To me this weird issue was occurring due to following line after implementation of UISplitViewController对我来说,这个奇怪的问题是由于 UISplitViewController 实现后的以下行而发生的
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
.
.
.
// splitViewController.preferredDisplayMode = .PrimaryOverlay
.
.
.
}
By commenting this line in didFinishLaunchingWithOptions issue was resolved.通过在 didFinishLaunchingWithOptions 中注释这一行问题已解决。
In my case, I forget to delete storyboard file.就我而言,我忘记删除故事板文件。 After I removed it, this warning is gone.
我删除它后,此警告消失了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.