iphone 利用代码向视图(view)添加按钮(button)
2012-05-10 11:08
381 查看
iphone 利用代码向视图(view)添加按钮(button) // 视图载入触发事件 // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { // 文件按钮 UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; button.frame = CGRectMake(20, 20, 200, 200); [button setTitle:@"Client" forState:UIControlStateNormal]; [button addTarget:self action:@selector(buttonClicked:)forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:button]; [super viewDidLoad]; } -(void)buttonClicked:(id)sender { NSLog(@"buttonClicked is used."); } |
相关文章推荐
- 利用Java代码给gridLayout动态添加button按钮
- iOS学习之动态添加Button和监听UIAlertView按钮
- iPhone开发之UIScrollView滚动组件的使用(七)利用NSTimer计时器和UIPageControl组件代码实现图片轮播器
- 关于UIScrollview添加子视图按钮无反应
- iOS 11开发教程(十八)iOS11应用视图之使用代码添加按钮
- 在imageView依次添加7个手势, 1.点击哪个按钮,往imageView上添加哪个手势.(保证视图上只有一个手势). 2.轻拍:点击视图切换美女图片.(imageView上首先展示的美女
- 在navigationbar上动态添加按钮,主视图动态删除按钮原理及代码讲解
- iPhone开发 Label,button,view,window控件的添加
- iPhone开发--在UITableView上添加悬浮按钮
- iOS学习之动态添加Button和监听UIAlertView按钮
- IOS 纯代码添加 Button Image Label 添加到自定义View中
- 利用Associative机制为UIAlertView添加一个Block属性,将AlertView与button的响应事件关联
- 安卓ListView的Item中添加按钮后,点击Button获取点击行的TextView文本数据
- Button按钮换脸viewpager滑动+点击监听 _____部分重点代码
- EXT中单击button按钮grid添加一行(光标位置可设置)的实例代码
- iOS学习之动态添加Button和监听UIAlertView按钮
- 在ImageView上添加Button并为图片做填充和为Button按钮设置透明度
- iOS 在tableView上添加button导致按钮没有点击效果和不能滑动的 zhuang
- 第三个引导页添加button按钮(滑动viewpager)