少尉

嗯。

 

objective c 手动创建按钮并绑定事件处理程序

- (void)createButton {   UIButton *myButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; myButton.frame = CGRectMake(100, 100, 100, 50); [myButton setTitle:@"click me!" forState:UIControlStateNormal]; SEL eventHandler = @selector(clickHandler); [myButton addTarget:self action:eventHandler forControlEvents:UIControlEventTouchUpInside]; [window addSubview:myButton]; }   - (void)clickHandler { NSLog(@"You clicked button!"); }

posted on 2012-08-20 14:10  moonvan  阅读(1017)  评论(0编辑  收藏  举报

导航