如何为每个按钮设置标题,以便将按钮标题设置为:1、2、3、4 5 等按钮?
我的按钮:
@interface PregnancyViewController () {
NSMutableArray *buttons;
}
@end
- (void)viewDidLoad
{
[super viewDidLoad];
for( int i = 0; i < 5; i++ ) {
for( int j = 0; j < 6; j++ ) {
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.frame = CGRectMake(j * 50 + 10, i * 50 + 20, 40, 40);
// Add buttons to my mutable array
[buttons addObject: button];
[button addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];
}
}
}