簡體   English   中英

iOS11 UIBarButtonItem無效

[英]iOS11 UIBarButtonItem not working

我在商店里有一個應用程序。 我試圖為iOS11版本做好准備,但遇到了煩人的問題。

應用程序中的UIBarButtonItem都沒有正常工作。 leftBarButtonItems是可點擊的,但點擊區域略微位於項目的右側。 rightBarButtonItems根本不起作用! 我通過故事板和代碼添加了這些項目,但它們似乎都沒有工作。 請幫忙!

這是一個例子: -

navigationItem.rightBarButtonItem = UIBarButtonItem(title: NSLocalizedString("Save", comment: "save button title"), style: UIBarButtonItemStyle.plain, target: self, action: #selector(VC.rightBarButtonClicked(_:)))

有同樣的問題。 它歸結為UIButton在我們項目中名為“UIButton + MinimumTouchArea.swift”的文件中的擴展,該文件覆蓋了UIButton.hitTest並在iOS 11中打破了UIBarButtonItem。我們花了一整天的時間才弄明白!

不會調用iOS11 UIBarButtonItem操作

遇到了同樣的問題,我的解決方案是用xcode 8.3構建(運行應用程序構建的ios11的設備運行良好)

在iOS 11中使用Xcode 8,您可以使用此解決方法在xcode 8.3上調試ios11設備

是的, iOS 11存在錯誤,因此您可以使用其他方式。

使用interactivePopGestureRecognizer類的

 self.navigationController?.interactivePopGestureRecognizer?.delegate = self as! UIGestureRecognizerDelegate

並實現委托方法

 func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
        guard gestureRecognizer == interactivePopGestureRecognizer else {
            return true // default value
        }

        // Write you code here.
    }

暫無
暫無

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

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