2011-12-18 28 views
12

我有一個UIActionSheet,我指定取消按鈕,但它不輕易當它的點擊?UIActionSheet取消按鈕不解僱行動表

UIActionSheet *actionSheet = [[[UIActionSheet alloc]initWithTitle:nil delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Target Complete" otherButtonTitles:nil] autorelease]; 
[actionSheet showInView:self.view]; 

據我不需要任何代碼,甚至當我嘗試並實現didCancel委託方法它永遠不會被調用的文件?

回答

3

如果您在視圖中使用顯示,您需要從iPhone上的任務欄或工具欄顯示剪輯某些控件。

42

試試這個

[actionSheet showInView:[self.view window]]; 

UIActionSheet cancel button strange behaviour

+1

這應該是公認的答案。 – 2013-06-12 13:20:17

+0

@nevan king:這對我不起作用,然後我沒有使用任何標籤欄或任務欄。我正在使用導航,那麼我怎樣才能取消按鈕取消 – TamilKing 2013-10-29 06:31:20

14

這將這樣的伎倆

[actionSheet showInView:[self.view window]]; 

,而不是

[actionSheet showInView:self.view]; 
0

寫simplite代碼

actionSheet.actionSheetStyle = UIActionSheetStyleDefault; 

這項工作很好

4

使用

[actionSheet showFromTabBar:[[self tabBarController] tabBar]]; 

代替

[actionSheet showInView:self.view]; 

這是工作的罰款.. :-)