在iphone sdk 4.3中单击按钮的警报消息
发布时间:2020-12-14 19:58:22 所属栏目:百科 来源:网络整理
导读:我是 xcode编程的初学者.当我们要点击xcode- iphone-4.3中的按钮时,请告诉我如何显示警告信息 我的守则如下, - (IBAction)buttonPressed:(id)sender{ UIAlertView* mes=[[UIAlertView alloc] initWithTitle:@"Hello World!!!!!!" message:@"This is the Ipho
我是
xcode编程的初学者.当我们要点击xcode-
iphone-4.3中的按钮时,请告诉我如何显示警告信息
我的守则如下, - (IBAction)buttonPressed:(id)sender{ UIAlertView* mes=[[UIAlertView alloc] initWithTitle:@"Hello World!!!!!!" message:@"This is the Iphone app" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles: nil]; [mes show]; [mes release]; 请帮我解决这个问题. 解决方法-(IBAction)buttonOnePressed:(id)sender { UIAlertView *alert = [[UIAlertView alloc]initWithTitle: @"Clicked button 1" message: @"Alert Message here" delegate: self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK",nil]; [alert setTag:1]; [alert show]; } -(IBAction)buttonTwoPressed:(id)sender { UIAlertView *alert = [[UIAlertView alloc]initWithTitle: @"Clicked button 2" message: @"Alert Message here" delegate: self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK",nil]; [alert setTag:2]; [alert show]; } 下面是跟踪Alertview上的哪个按钮的委托方法. -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { if (alertView.tag == 1) { // UIAlertView with tag 1 detected if (buttonIndex == 0) { NSLog(@"user pressed Button Indexed 0"); // Any action can be performed here } else { NSLog(@"user pressed Button Indexed 1"); // Any action can be performed here } } else if (alertView.tag == 2) { // UIAlertView with tag 2 detected if (buttonIndex == 0) { NSLog(@"user pressed Button Indexed 0"); // Any action can be performed here } else { NSLog(@"user pressed Button Indexed 1"); // Any action can be performed here } } } 如果您有多个UIAlertViews,可以将标记设置为UIAlertView,并且可以使用其各自的标记确定在其委托方法clickedButtonAtIndex中单击了哪个UIAlertView按钮. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |