UIButton

 

 

UIButton

 

Pasted Graphic.tiff

 

 

 

xib相关的按钮的事件处理函数:

- (IBAction)buttonClick:(id)sender

{

UIButton *button = (UIButton *)sender;

NSString *title = [NSString stringWithFormat:@"Button tag %d",button.tag];

NSString *message = [button currentTitle];

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title

          message:message

                delegate:self

                    cancelButtonTitle:nil];

[alert show];

  [alert release];

}

 

 

//给按钮增加一个处理消息函数 

- (void)addTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents;

 

//删除按钮的消息处理函数

- (void)removeTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents;

 

//手动创建button

UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];

button.frame = CGRecdtMake(...);

[button setTitle:@"start" forState:UIControlStateNormal];

[button addTarget:self action:@selector(buttonClick:) forControlEvents:UIControleEventsTouchUpInside];

button.tag = 6;

 

你可能感兴趣的:(UIButton)