[英]Cancel button from UIActionSheet doesn't appear after long press on phone number in UITextView
[英]ios UIActionSheet cancel button doesn't work right
我有這個問題:這是我的代碼:
UIActionSheet *popupQuery = [[UIActionSheet alloc] initWithTitle:@"Share the race" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Send with mail" otherButtonTitles:nil];
popupQuery.actionSheetStyle = UIActionSheetStyleBlackTranslucent;
[popupQuery showInView:self.view];
[popupQuery release];
一切似乎都很好,2個按鈕顯示正確,“發送郵件”按鈕還可以,但取消點擊只在上方......這里有一個說明情況的鏡頭:
我該如何解決這個問題?
謝謝:)
我的猜測是UIActionSheet
的底部超出了視圖的范圍,因此不響應觸摸。
為了測試這個理論,添加另一個按鈕並查看是否所有上部按鈕都正常工作,但底部按鈕仍然表現出這種行為。
要解決此問題,請確保視圖延伸到屏幕底部。 如果您的應用程序中有一個 tabBar,那將是我對問題的懷疑。 您可以使用showFromTabBar:
如果您希望 tabBar 上方的工作表,或showFromToolbar:
從工具欄中顯示它。
如果您沒有底欄,那么我錯了,不知道。
您應該將操作表顯示為應用程序 window 的子視圖,而不是當前視圖的子視圖。
UIActionSheet *actionSheet = [[UIActionSheet alloc] init...];
// ...
[actionSheet showInView:[UIApplication sharedApplication].keyWindow];
也許它會幫助別人。
快樂編碼:)
利用
[actionSheet showFromTabBar:[[self tabBarController] tabBar]];
代替
[actionSheet showInView:self.view];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.