簡體   English   中英

Swift Unbalanced 調用開始/結束外觀過渡

[英]Swift Unbalanced calls to begin/end appearance transitions for

這已經讓我難住了一段時間。 我在UITabBarController有一個UISplitViewController 主視圖是一個 TableView。 當我單擊一個單元格時,我會調出一個非常基本的視圖控制器,其中只有一個UIButton居中。 這是視圖控制器的代碼:

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 時,問題出現了,我收到:

Unbalanced calls to begin/end appearance transitions for <TestViewController: 0x7fb882a72380>.

TestViewController是非常基礎的,那么為什么會發生這種情況呢?

如果您在上一個事務(動畫)正在進行時嘗試推送新的視圖控制器,則會出現此問題。 因此,請檢查您的代碼流程並進行適當的更改。 檢查您的關閉和呈現視圖動畫。 您可以使用屬性 setAnimation 來“是/否”解決此問題

設置動畫:NO,可能會解決您的問題

對我來說,這個奇怪的問題是由於 UISplitViewController 實現后的以下行而發生的

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
.
.
.
    // splitViewController.preferredDisplayMode = .PrimaryOverlay
.
.
.
    }

通過在 didFinishLaunchingWithOptions 中注釋這一行問題已解決。

就我而言,我忘記刪除故事板文件。 我刪除它后,此警告消失了。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM