滚动广告条,一行两个值 如何分配行数
if (0 == row) {
cell = [[HSTableViewCellalloc]initWithFirstRow:UITableViewCellStyleDefaultreuseIdentifier:indentifier :[selfcreateBanner]];
}
- (SGFocusImageFrame*)createBanner
{
unsigned long length = [mArrBanner count];
NSMutableArray *tempArray = [NSMutableArrayarrayWithArray:mArrBanner];
NSMutableArray *itemArray = [NSMutableArray arrayWithCapacity:length+2];
//添加最后一张图用于循环
if (length > 1) {
NSDictionary *dict = [tempArray objectAtIndex:length-1];
SGFocusImageItem *item = [[SGFocusImageItem alloc] initWithDict:dict tag:-1];
[itemArray addObject:item];
}
for (int i = 0; i < length; i++) {
NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithDictionary:[tempArray objectAtIndex:i]];
NSString *strImgUrl = [dict objectForKey:@"img_url"];
NSString *smallImgUrl = [NSString stringWithFormat:@"%@695.jpg", strImgUrl];
[dict setValue:smallImgUrl forKey:@"img_url"];
SGFocusImageItem *item = [[SGFocusImageItem alloc] initWithDict:dict tag:i];
[itemArray addObject:item];
}
//添加第一张图用于循环
if (length >1) {
NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithDictionary:[tempArray objectAtIndex:0]];
NSString *strImgUrl = [dict objectForKey:@"img_url"];
NSString *smallImgUrl = [NSString stringWithFormat:@"%@695.jpg", strImgUrl];
[dict setValue:smallImgUrl forKey:@"img_url"];
SGFocusImageItem *item = [[SGFocusImageItem alloc] initWithDict:dict tag:length];
[itemArray addObject:item];
}
SGFocusImageFrame *bannerView = [[SGFocusImageFramealloc] initWithFrame:CGRectMake(0, 0, mScWidth, BANNER_HEIGHT)
delegate:self
imageItems:itemArray
isAuto:YES];
return bannerView;
}
#pragma mark - SGFocusImageFrameDelegate
- (void)foucusImageFrame:(SGFocusImageFrame *)imageFrame didSelectItem:(SGFocusImageItem *)item
{
NSDictionary *toptc = [mArrBanner objectAtIndex:item.tag];
NSString *title = [toptc objectForKey:@"toptc_title"];
NSString *imgUrl = [toptc objectForKey:@"img_url"];
NSString *toptz = [toptc objectForKey:@"toptc_param"];
NSString *toptzUrl = [toptc objectForKey:@"toptc_url"];
if (nil != toptzUrl) {
HSUrlWebViewController *webViewController = [[HSUrlWebViewController alloc] initWithTitle:title :toptzUrl];
[[HSNavigationController shareNavController] pushViewController:webViewController animated:YES];
} else {
HSTopicClassViewController *sigleViewController = [[HSTopicClassViewController alloc] initWithTitle:title iamge:imgUrl param:toptz];
[[HSNavigationController shareNavController] pushViewController:sigleViewController animated:YES];
}
}
#pragma mark - UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return mArrApp.count % 2 + mArrApp.count / 2 + 1;
}