0
我有一個由3個標籤,名稱,書籍和章節組成的自定義單元格的tableView。不幸的是,我的單元格似乎不夠3個標籤,我想把它做得更大。我應該如何在我的代碼中以最佳方式實現這一目標? /問候增加tableView的單元格的大小?
圖片細胞的中的tableView:http://tinypic.com/view.php?pic=2vrzpu9&s=6
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"BookmarkCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
Bookmark *item = [self.items objectAtIndex:indexPath.row];
NSArray *chunks = [item.name componentsSeparatedByString: @","];
NSString *name;
NSString *book;
NSString *chapter;
if ([chunks count] > 0)
{
name = [chunks objectAtIndex:0];
if ([chunks count] > 1)
{
book = [chunks objectAtIndex:1];
if ([chunks count] > 2)
{
chapter = [chunks objectAtIndex:2];
}
}
}
UIView * pNewContentView= [[UIView alloc] initWithFrame:cell.contentView.bounds];
CGRect labelFrame= pNewContentView.bounds;
labelFrame.size.height= labelFrame.size.height * 0.25;
UILabel* pLabel1=[[UILabel alloc] initWithFrame:labelFrame];
[pNewContentView addSubview:pLabel1];
labelFrame.origin.y= labelFrame.size.height;
UILabel* pLabel2=[[UILabel alloc] initWithFrame:labelFrame];
[pNewContentView addSubview:pLabel2];
labelFrame.origin.y= labelFrame.origin.y + labelFrame.size.height;
UILabel* pLabel3=[[UILabel alloc] initWithFrame:labelFrame];
[pNewContentView addSubview:pLabel3];
[cell.contentView addSubview:pNewContentView];
[pLabel1 setText:(name)];
[pLabel2 setText:(book)];
[pLabel3 setText:(chapter)];
//cell.textLabel.text = chapter;
//cell.textLabel.text = name;
//cell.detailTextLabel.text = book;
return cell;
}
感謝名單,它的工作! –