在iPhone应用的table cell中添加自定义布局view
在iPhone开发中,tableView提供了通过nib自定义视图的解决方案。这就使开发者能够完成相当复杂的界面布局。下面介绍table中添加自定义的table cell。实现的效果如下:

实现过程很简单,首先创建一个table视图,添加table相应的协议。
接下来,新建文件,并在 subclass 里 选择 UITableViewCell 这里我命名为 “MyCell”
然后在利用IB创建一个名为mycell的nib,在里面拖入一个UITableViewCell并将其类名改为MyCell。

实现具体的类:
-(NSInteger) tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section
{
return 1;
}- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"CustomCellIdentifier";
MyCell *cell = (MyCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *array = [[NSBundle mainBundle] loadNibNamed:@"mycell" owner:self options:nil];
cell = [array objectAtIndex:0];
[cell setSelectionStyle:UITableViewCellSelectionStyleGray];
}
[[cell lable] setText:@"你好"];
//[[cell imageView] setImage:[UIImage imageNamed:[imageNameArray objectAtIndex:indexPath.row]]];
//[[cell nameLabel] setText:[nameArray objectAtIndex:indexPath.row]];
return cell;
}
- (CGFloat)tableView:(UITableView *)atableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return 90;
}