你好,游客 登录 注册 搜索
背景:
阅读新闻

iOS开发教程之动态添加Button和监听UIAlertView按钮

[日期:2012-07-29] 来源:Linux社区  作者:totogo2010 [字体:大 中 小]

二、监听UIAlertView。

1、在上面的代码基础上,在addbuttonViewController.h文件添加委托

  1. #import <UIKit/UIKit.h>   
  2.   
  3. @interface addbuttonViewController : UIViewController<UIAlertViewDelegate>  
  4. - (IBAction)addButton:(id)sender;  
  5.   
  6. @end  

2、在AlertView中多添加两个按钮

  1. -(void) someButtonClicked{    
  2.     UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示"   
  3.                                                     message:@"您点击了动态按钮!"     
  4.                                                    delegate:self     
  5.                                           cancelButtonTitle:@"确定"    
  6.                                           otherButtonTitles:@"取消",@"第三项",nil];    
  7.     [alert show];  
  8. }  

效果图:

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款