- (void)setDataSource:(NSArray *)array{
if ([array isKindOfClass:[NSArray class]] && array.count > 0) {
NSInteger totalCount= array.count;
NSInteger row = ceilf(totalCount*0.5);
for (int i=0; i< row; i++) {
for (int j = 0; j< 3; j++) {
NSInteger indx = i*3+j;
if (indx < totalCount ) {
NSDictionary *diction = [NSDictionary dictionaryWithDictionary:array[indx]];
NSString *titleString = [NSString stringWithFormat:@"%@",diction[@"dictionaryName"]];
UIButton *itemButton = [UIButton buttonWithType:UIButtonTypeCustom];
itemButton.frame = CGRectMake(8+98*j, 12+40*i, 90, 26);
[itemButton setTitle:titleString forState:UIControlStateNormal];
[itemButton setTitleColor:[MMColor c666666Color] forState:UIControlStateNormal];
[itemButton setBackgroundColor:[UIColor whiteColor]];
itemButton.titleLabel.font = [UIFont systemFontOfSize:12];
itemButton.tag = indx;
[self.rootView addSubview:itemButton];
[itemButton setCornerRadius:13];
}
}
}
self.cellHeight = 27*row+100;
}
}