メインビューで呼び出される行に5つのイメージがあるカスタムセルFeatureCellを作成しましたが、それを呼び出すと空の行が表示されます。だから私の問題がどこにありますか?1つのUITableViewの問題で2つの異なるカスタムセルを呼び出す
私はカスタムセルについて調べていますが、私は以下のコードで使用しなければならない方法を使用しましたが、何も起こりません。
この
は、これは私の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アウトレットではどういう意味ですか? –