-(IBAction)indexCityView:(id)sender
{
int buttonViewTag = 1110 ;//移出scrollview上面的 button,设置tag的起始值
for (int i =buttonViewTag; i<1110 + self.cityList.count; i++) {
[[self.viewviewWithTag:i] removeFromSuperview];
}
UIButton *button = (UIButton *)sender;
int btnTag = button.tag;
int row = 0;//行
int column = 0;//列
BOOL nextLineFlag = NO;
int frontRampage = 0;
switch (btnTag) {
case 0:
for (int i = 0; i< aEArray.count; i++) {
NSArray *temp = [aEArray objectAtIndex:i];
for (int j = 0; j<temp.count; j++) {
HFCity *hfCity = [temp objectAtIndex:j];
UIButton *btn = [[UIButton alloc] init];
[UIButtonbuttonWithType:UIButtonTypeRoundedRect];
[btn setTitle:hfCity.cityName forState:UIControlStateNormal];
[btn setTitleColor:[UIColorcolorWithRed:128/255green:128/255blue:128/255alpha:1] forState:UIControlStateNormal];
[btn setTitleColor:[UIColorcolorWithRed:0/255.0green:132/255.0blue:26/255.0alpha:1] forState:UIControlStateHighlighted];
[btn addTarget:selfaction:@selector(chooseCity:) forControlEvents:UIControlEventTouchUpInside];
buttonViewTag++;
btn.tag = buttonViewTag;
if (nextLineFlag) {
row = row +1;
frontRampage = row;
nextLineFlag = NO;
}else{
row = j/4 + frontRampage;
}
column = j%4;
int x = column*70;
int y = row*30;
btn.frame = CGRectMake(x, y, 70, 30);
[self.cityScrollView addSubview:btn];
}
nextLineFlag = YES;
}
self.cityScrollView.contentSize = CGSizeMake(70*column, 44*row);//width,height
break;
default:
break;
}
}今天的情感基调定下来了,呵呵,喘一口气,