[英]iOS 11 issue - bar button action does not fire if gesture added to navigation bar
這在iOS 10上運行良好。但是在iOS 11 showFlyoutMenu
無法運行showFlyoutMenu
沒有啟動。
gestureLeftArrow = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(leftArrowGesture:)];
[self.navigationController.navigationBar addGestureRecognizer:gestureLeftArrow];
gestureRightArrow = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(rightArrowGesture:)];
[self.navigationController.navigationBar addGestureRecognizer:gestureRightArrow];
UIImage *image = [[UIImage imageNamed:@"hamburger-new.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
UIBarButtonItem *flyoutButton = [[UIBarButtonItem alloc] initWithImage:image style:UIBarButtonItemStylePlain target:self action:@selector(showFlyoutMenu)];
self.navigationItem.rightBarButtonItem = flyoutButton;
您應該將手勢識別器的cancelsTouchesInView
設置為false
。
請參閱: cancelsTouchesInView
討論區
當此屬性為true(默認值)並且接收方識別出其手勢時,該手勢的未決觸摸不會傳遞到視圖,並且先前發送的觸摸會通過發送給視圖的touchesCancelled(_:with :)消息取消。 如果手勢識別器無法識別其手勢,或者此屬性的值為false,則視圖將接收多點觸摸序列中的所有觸摸。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.