2015-05-05 10 views
6

Điều này đã khiến tôi khó chịu trong một thời gian. Tôi có một số UISplitViewController bên trong một số UITabBarController. Chế độ xem chính là một TableView. Khi tôi nhấp vào một ô, tôi sẽ hiển thị bộ điều khiển chế độ xem cơ bản chỉ với một trung tâm UIButton. Đây là mã cho bộ điều khiển chế độ xem:Cuộc gọi nhanh không cân bằng để chuyển đổi giao diện bắt đầu/kết thúc cho

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) 
    } 
} 

Nếu tôi nhấp vào hủy hoặc chọn và hình ảnh, trình điều khiển bộ chọn sẽ loại bỏ chính xác. vấn đề này được đưa ra khi tôi nhấp vào nút quay lại để trở về TableView, tôi nhận được:

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

các TestViewController là rất cơ bản, vậy tại sao điều này sẽ xảy ra?

+0

Khi bạn quay lại 'tableView', có lẽ' tableView' đã cố gắng trình bày vc này một lần nữa? – Schemetrical

Trả lời

7

Sự cố này xảy ra nếu bạn cố gắng đẩy bộ điều khiển chế độ xem mới trong khi đang thực hiện giao dịch trước đó (hoạt ảnh). Vì vậy, hãy kiểm tra lưu lượng mã của bạn và thực hiện các thay đổi thích hợp. Kiểm tra hoạt ảnh xem và loại bỏ chế độ xem hiện tại của bạn. Bạn có thể sử dụng setAnimation tài sản để 'YES/NO'resolve

Set này hoạt hình: NO, có thể giải quyết vấn đề của bạn

+5

Cảm ơn sự giúp đỡ của bạn. Kỳ lạ là nó đã giúp tôi theo dõi vấn đề, trong phương thức viewDidAppear của UITabBarController, tôi đã bỏ lỡ dòng: super.viewDidAppear (hoạt hình). –

1

Đối với tôi vấn đề kỳ lạ này đã xảy ra do dòng sau sau khi thi hành UISplitViewController

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

Bằng cách nhận xét dòng này trong vấn đề didFinishLaunchingWithOptions đã được giải quyết.

Các vấn đề liên quan