주 뷰에서 호출 될 행에 5 개의 이미지가있는 사용자 정의 셀 FeatureCell을 만들었지 만 호출 할 때 빈 행이 표시됩니다. 그래서 내 문제가 될 수있는 곳으로?하나의 UITableView 문제에서 두 개의 다른 사용자 정의 셀 호출
나는 사용자 정의 셀에 대해 봤지만 나는 아래 코드에서 사용해야하지만 아무 일도 일어나지 않았다.
이
이 내 FeatureCell.m 내 FeatureCell.h@interface FeatureCell : UITableViewCell{
IBOutlet UIImageView *img1;
IBOutlet UIImageView *img2;
}
@property (nonatomic, retain) UIImageView *img1;
@property (nonatomic, retain) UIImageView *img2;
@end
입니다
@implementation FeatureCell
@synthesize img,img1,img2,img3,img4;
@end
이것은 내보기 컨트롤러이다하는 .m
- (NSInteger) numberOfSectionsInTableView:(UITableView *)tableView{
return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
if (section == 0) {
return [objectCollection count];
}
else{
return 1;
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString* cellIdentifier1 = @"FeatureCell";
FeatureCell *cell1 = (FeatureCell*)[tableView dequeueReusableCellWithIdentifier:cellIdentifier1];
if (cell1 == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:cellIdentifier1 owner:nil options:nil];
cell1 = (FeatureCell*)[nib objectAtIndex:0];
}
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1
reuseIdentifier:CellIdentifier];
}
if ([indexPath section] == 0) {
containerObject = [objectCollection objectAtIndex:indexPath.row];
[[cell textLabel] setText:containerObject.store];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
else{
cell1.img1.image = [UIImage imageNamed:@"shower.png"];
cell1.img2.image = [UIImage imageNamed:@"parking.png"];
}
return cell;
}
당신이 콘센트를 연결 했 내 문제 해결? – Wain
이것은 2 가지 다른 세포 유형을 다루는 올바른 방법이 아닙니다. 내 대답보기 : http://stackoverflow.com/questions/17711452/change-uicollectionviewcell-content-and-nib-layout-based-on-data/17711644#17711644. 컬렉션 뷰를 다루지 만 테이블 뷰에서도 마찬가지입니다. – rdelmar
@Wain 콘센트는 무엇을 의미합니까? –