我在用戶單擊操作表單中的「destructButton」後實現了一個警報視圖。代碼片段如下:目標C:AlertView不起作用
-(void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex
{
if (buttonIndex != actionSheet.cancelButtonIndex)
{
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Something happened!"
message:nil
delegate:nil
cancelButtonTitle:@"Phew!"
otherButtonTitles:nil];
}
[alert show];
[alert release];
}
我已經包含在我的.h文件中
@interface Control_FunViewController : UIViewController <UIActionSheetDelegate> {
UITextField *nameField;
UITextField *numberField;
UILabel *sliderLabel;
UISwitch *leftSwitch;
UISwitch *rightSwitch;
UIButton *doSomethingButton;
}
的UIActionSheetDelegate協議,但是當我在actionsheet點擊destructButton,沒有任何反應。我在這裏錯過了什麼嗎?
感謝
震
我不認爲你的代碼甚至可以編譯。爲什麼'alert'顯示在定義範圍之外? – kennytm 2011-04-05 05:26:09