我在用户单击操作表单中的“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