您的位置:首页 > 编程语言

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.");

}

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐