Ios 多个自定义单元格';s在单UITableView中
试图在一个uitableview中获取多个自定义单元格,但目前它不起作用,它所做的只是使用第一个if语句块来设置单元格外观。 我该怎么办谢谢你的回复,Daniel Ran 代码如下:Ios 多个自定义单元格';s在单UITableView中,ios,cocoa-touch,uitableview,Ios,Cocoa Touch,Uitableview,试图在一个uitableview中获取多个自定义单元格,但目前它不起作用,它所做的只是使用第一个if语句块来设置单元格外观。 我该怎么办谢谢你的回复,Daniel Ran 代码如下: -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { if(indexPath.row == 0) { //Facebook Tile
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
if(indexPath.row == 0) {
//Facebook Tile//
static NSString *FacebookCellID = @"FacebookCellID";
FacebookTileCell *FacebookCell = (FacebookTileCell *)[tableView dequeueReusableCellWithIdentifier:FacebookCellID];
if (FacebookCell == nil) {
NSString *XIBStringFacebookTile;
XIBStringFacebookTile = @"FacebookTileCell";
NSArray *FacebookTileArray = [[NSBundle mainBundle] loadNibNamed:XIBStringFacebookTile owner:self options:nil];
NSUInteger FacebookInteger;
FacebookInteger = 0;
FacebookCell = [FacebookTileArray objectAtIndex:FacebookInteger];
UIView *CellSelectedStyle = [[UIView alloc] init];
UIColor *CellSelectedStyleColor = [UIColor FacebookColor];
CellSelectedStyle.backgroundColor = CellSelectedStyleColor;
[FacebookCell setBackgroundView:CellSelectedStyle];
}
return FacebookCell;
}
else if (indexPath.row == 1) {
//Twitter Tile//
static NSString *TwitterCellID = @"TwitterCellID";
TwitterTileCell *TwitterCell = (TwitterTileCell *)[tableView dequeueReusableCellWithIdentifier:TwitterCellID];
if (TwitterCell == nil) {
NSString *XIBStringTwitterTile;
XIBStringTwitterTile = @"TwitterTileCell";
NSArray *TwitterTileArray = [[NSBundle mainBundle] loadNibNamed:XIBStringTwitterTile owner:self options:nil];
NSUInteger TwitterInteger;
TwitterInteger = 0;
TwitterCell = [TwitterTileArray objectAtIndex:TwitterInteger];
UIView *CellSelectedStyle = [[UIView alloc] init];
UIColor *CellSelectedStyleColor = [UIColor TwitterColor];
CellSelectedStyle.backgroundColor = CellSelectedStyleColor;
[TwitterCell setBackgroundView:CellSelectedStyle];
}
return TwitterCell;
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
//refine algorithm//
return self.view.frame.size.height/NumberofTiles;
NSLog(@"Flexible Tile Height = %d", NumberofTiles);
//imbed switch case statement later on//
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
//Just one section in FeedbackTableView//
return NumberofTiles;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 1;
}
这是你的问题:
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 1;
}
你是说你只有一个细胞。完全有效!你刚刚救了我你知道的。。谢谢;)