我的守则如下,
- (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按钮.
总结以上是内存溢出为你收集整理的在iphone sdk 4.3中单击按钮的警报消息全部内容,希望文章能够帮你解决在iphone sdk 4.3中单击按钮的警报消息所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)