2013-02-02 22 views
1

我想有沒有破壞性的按鈕,會彈出一個動作片。如果我只是試圖從下面的代碼中刪除破壞性按鈕,我得到一個錯誤:UIActionSheet沒有可見的接口。有誰知道爲什麼會發生這種情況?我如何刪除紅色破壞性按鈕?謝謝!消除紅眼破壞性按鈕可以從ActionSheet

UIActionSheet *popupQuery = [[UIActionSheet alloc] initWithTitle:@"Title" 
delegate:self cancelButtonTitle:@"Cancel Button" destructiveButtonTitle:@"Destructive 
Button" otherButtonTitles:@"Other Button 1", @"Other Button 2", nil]; 
+1

另外請注意,這個問題有絕對無關,與使用的IDE,所以你不能以「Xcode的」標記它。 – 2013-02-02 09:42:34

+0

不要在「destructiveButtonTitle」傳什麼,只是將其設置爲nil –

回答

8

只是通過nil爲您的destructiveButtonTitle

只需用下面的代碼試試:

UIActionSheet *popupQuery = [[UIActionSheet alloc] initWithTitle:@"Title" delegate:self cancelButtonTitle:@"Cancel Button" destructiveButtonTitle:nil otherButtonTitles:@"Other Button 1", @"Other Button 2", nil]; 
+0

釘它。非常感謝!將很快標記正確。 – Brandon

+0

@Brandon:感謝您的評論:)祝你好運 –

+1

@Brandon你在正確的學習Objective-C的TE嚴重的需要。如果不知道正確的語法,則不應嘗試創建複雜的應用程序。 – 2013-02-02 09:41:27

3

I get an error: No visible interface for UIActionSheet.

護理進一步看過嗎?該消息實際上是

No visible interface for UIActionSheet declares the selector initWithTitle:delegate:cancelButtonTitle:otherButtonTitles:

是的,因爲沒有名稱的初始化程序。你不能「刪除」的論點是這樣的(因爲它改變了方法的名稱,並你爲什麼會想到不存在的方法存在嗎?

你可以簡單地通過nil的破壞性按鈕標題來代替。