.h代码如下@interface demo4ViewController : UIViewController
<UIAlertViewDelegate>{}-(IBAction)myclick:(id)sender;
.m代码如下-(IBAction)myclick:(id)sender
{
UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"title" message:@"message" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:@"option 1",@"option2",nil];
[alert show];
}-(void)alertView:(UIAlertView *)alertView buttonAtIndex:(NSInteger)buttonIndex{
NSLog([NSString stringWithFormat:@"%d",buttonIndex]);
}为什么运行了以后控制台不输出东西??根本就进不了alertView方法.怎么办?
<UIAlertViewDelegate>{}-(IBAction)myclick:(id)sender;
.m代码如下-(IBAction)myclick:(id)sender
{
UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"title" message:@"message" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:@"option 1",@"option2",nil];
[alert show];
}-(void)alertView:(UIAlertView *)alertView buttonAtIndex:(NSInteger)buttonIndex{
NSLog([NSString stringWithFormat:@"%d",buttonIndex]);
}为什么运行了以后控制台不输出东西??根本就进不了alertView方法.怎么办?
NSLog([NSString stringWithFormat:@"%d",buttonIndex]);
} 这个里面只有一个log 输出你想有什么反应
貌似方法必须叫这个名字