解决方案 »
- 关于IPHONE内存的困惑,跪求!!!!!!!
- IN app purchase
- UIButton与UIPickerView的问题
- 多线程下载的问题```
- 请问 NSUerDefault中可以存储NSMutableArray吗?
- 如何点击自定义cell里自定义的view时获得cell的indexpath
- TabBarController 的tabbar是空白的,但有切换效果
- ios 调用webserver 接口
- IOS 导航栏隐藏失效!!
- APP Store线上Crash统计捕捉问题
- 怎样让uiwebview里 点击的网页链接 支持uinavigationbar的返回操作?
- 求理解 UIApplicationmain函数调用语法
static NSString *myCellIdentifier = @"LifeShopsList";
LifeShopsList *cell = (LifeShopsList *)[tableView dequeueReusableCellWithIdentifier:myCellIdentifier];
if (cell == nil) {
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"LifeShopsList" owner:nil options:nil];
for(id currentObject in topLevelObjects)
{
if([currentObject isKindOfClass:[LifeShopsList class]])
{
cell = (LifeShopsList *)currentObject;
LIFE *news;
if (self.nshowid) {
if ([indexPath row]==0) {
[cell.title setHidden:YES];
[cell.distance setHidden:YES];
[cell.image setHidden:YES];
[cell.address setHidden:YES];
[cell.times setHidden:YES];
[cell.level setHidden:YES];
cell.imageally.hidden=YES;
cell.lbldistancetext.hidden=YES;
cell.lblleveltext.hidden=YES;
[self databack];
return cell;
}
news = [self.list objectAtIndex:[indexPath row]+2];
}
else
{
news = [self.list objectAtIndex:[indexPath row]];
}
if ([news.ally isEqualToString:@"1"]) {
[cell.title setFrame:CGRectMake(122, 15, 189, 21)];
}
else
{
cell.imageally.hidden=YES;
}
cell.title.text = news.name;
cell.distance.text = news.distance;
cell.image.placeholderImage = [UIImage imageNamed:@"背景图.PNG"];
// self.imageMidView.page = self.page;
if (news.imageMidURL!=nil&&![news.imageMidURL isEqualToString:@""]){
// NSURL *imageUrlqr = [NSURL URLWithString:news.imageMidURL];
// self.imageMidView.imageURL = [NSString stringWithFormat:@"%@",imageUrlqr];
[cell.image setImageURL:[NSURL URLWithString:news.imageMidURL]];
}
else
{
[cell.image setImage:[UIImage imageNamed:@"背景图.PNG"]];
}
cell.address.text=news.address;
cell.times.text=news.time;
switch ([news.level integerValue]) {
case 1:
[cell.level setImage:[UIImage imageNamed:@"1星.png"]];
break;
case 2:
[cell.level setImage:[UIImage imageNamed:@"2星.png"]];
break;
case 3:
[cell.level setImage:[UIImage imageNamed:@"3星.png"]];
break;
case 4:
[cell.level setImage:[UIImage imageNamed:@"4星.png"]];
break;
case 5:
[cell.level setImage:[UIImage imageNamed:@"5星.png"]];
break;
default:
break;
}
cell.contentView.backgroundColor = [UIColor clearColor];
UIView *aView = [[UIView alloc] initWithFrame: cell.contentView.frame];
UIColor *cellColor = nil;
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"nightMode"]){
cell.title.textColor = [UIColor colorWithRed:164.0/255 green:165.0/255 blue:169.0/255 alpha:1.0f];
cell.image.alpha = 0.5;
cellColor = [UIColor colorWithRed:34.0/255 green:34.0/255 blue:34.0/255 alpha:1.0f];
// tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
self.separatorImageView.image = [UIImage imageNamed:@"页面分割线.png"];
}else{
cell.title.textColor = [UIColor blackColor];
cell.image.alpha = 1;
cellColor = [UIColor colorWithRed:221.0/255 green:221.0/255 blue:221.0/255 alpha:1.0f];
self.separatorImageView.image = [UIImage imageNamed:@"页面分割线2.png"];
//tableView.separatorStyle = UITableViewCellSelectionStyleGray;
}
aView.backgroundColor = cellColor;
cell.selectedBackgroundView = aView; // 设置选中后cell的背景颜色
break;
}
}
}
return cell;这是我的一段代码,注意看红色部分
也可以这么写
{
if (indexPath.row==1) { //第一行
static NSString *simpleTableIdentifier = @"SimpleTableCell";
SimpleTableCell *cell = (SimpleTableCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if(cell == nil) {
cell= [[[NSBundle mainBundle] loadNibNamed:@"SimpleTabelCell" owner:self options:nil] lastObject];;
}
cell.imageview_1 = [UIImage imageNamed:@"1.png"];
cell.imageview_2 = [UIImage mageNamed:@"2.png"];
return cell;
}
if (indexPath.row==2) { //第二行
static NSString *simpleTableIdentifier = @"SimpleTableCell2";
SimpleTableCell2 *cell = (SimpleTableCell2 *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if(cell == nil) { cell= [[[NSBundle mainBundle] loadNibNamed:@"SimpleTableCell2" owner:self options:nil] lastObject];;
}
cell.imageview_1.image = [UIImage imageNamed:@"3.png"];
cell.imageview_2.image = [UIImage imageNamed:@"4.png"];
cell.imageview_3.image = [UIImage imageNamed:@"5.png"];
return cell;
}
return nil;
}