[英]In UIActionSheet the cancel button not showing for iphone?
在我的應用程序中,當我單擊更改圖像時,它要求UIActionsheet進行三項操作:拍照,從庫中選擇並取消。拍照,從庫中進行選擇正在顯示,但取消沒有顯示出問題所在。 這是我的代碼
- (void)viewDidLoad
{
[super viewDidLoad];
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Select Image from..."
delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Take Photo", @"Choose from library", nil];
actionSheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent;
actionSheet.actionSheetStyle = UIActionSheetStyleDefault;
[actionSheet showInView:self.view];
}
這是因為...我認為您使用的是默認的視圖大小-Retina 4全屏作為視圖大小...只需嘗試從屬性檢查器將視圖大小更改為Retina 3.5全屏... !!!
試試這個...
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Select Image from..."
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:@"Cancel"
otherButtonTitles:@"Take Photo", @"Choose from library", nil];
actionSheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent;
actionSheet.actionSheetStyle = UIActionSheetStyleDefault;
[actionSheet showInView:self.view];
您可能需要看一看在類參考中提供操作表的替代方法。 但是,您可能要嘗試使用以下方法之一(如果有工具欄)
– showFromBarButtonItem:animated:
– showFromToolbar:
此外,使用以下內容
actionSheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent;
actionSheet.actionSheetStyle = UIActionSheetStyleDefault;
只會導致動作表樣式為默認樣式。
請參考此鏈接 。
您也可以參考以下代碼,它可能對您有幫助:
(void)viewDidLoad
{
UIActionSheet * actionSheet = [[UIActionSheet alloc] initWithTitle:@"Select Image from..." delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Take Photo", @"Choose from library", nil];
[actionSheet showInView:self.view];
}
由於您的問題不在於您的代碼。 也許您使用了錯誤的方法來顯示UIActionSheet。
可以使用以下方法顯示UIActionSheet:
– showFromTabBar:
– showFromToolbar:
– showInView:
– showFromBarButtonItem:animated:
– showFromRect:inView:animated:
由於使用的是TabBar,“取消”按鈕也可能位於下方。 我也會測試。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.