您好我是iphone新手。我所做的是在視圖中創建一組按鈕。我的代碼是作爲休耕地如何從一組按鈕中獲取所有按鈕標記值
- (void)mymethod1 {
UIView *view = [[UIView alloc]initWithFrame:[[UIScreen mainScreen]bounds]];
int row = 0;
int column = 0;
for (int i=6; i<_images.count; i++) {
buttonimage = [UIButton buttonWithType:UIButtonTypeCustom];
buttonimage.frame = CGRectMake(column*60+5, row*60+5, 70,70);
[buttonimage setImage:[UIImage imageNamed:[_images objectAtIndex:i]] forState:UIControlStateNormal];
buttonimage.tag = i;
[buttonimage addTarget:self
action:@selector(buttonClicked:)
forControlEvents:UIControlEventTouchUpInside];
buttonimage.tag = i;
[view addSubview:buttonimage];
if (column == 4) {
column = 0;
row++;
} else {
column++;
}
}
self.view = view;
[ view release];
}
它工作正常。但是當過我所說的所有的按鈕在任何其他功能它得到最後一個按鈕僅適用於如:
- (void)mymethod2 {
NSLog(@"button value %d",buttonimage.tag);
}
「得到它在控制檯按鈕值5」。但我需要得到所有mymethod2按鈕標籤值。我怎麼能得到所有的按鈕標籤值。請張貼一些code.Thank你提前。