UITableViewController单元设计问题

时间:2011-09-21 17:12:40

标签: iphone ios interface-builder uitableview

我有一个带有附加xib文件的UITableViewController。在xib文件中,我有一个TableViewCell对象,其中包含一个视图以及视图上的标签。下面是我的结果应该是什么的图像:

pic1 http://casperslynge.dk/2.png

下面是我的tableview的样子。

pic2 http://casperslynge.dk/iphone1.png

我的问题是我无法让表格视图单元格填满整个窗口。尝试过界面构建​​器中的所有内容。与原点或宽度/高度无关。下面是我使用xib文件实例化我的单元格并用数据填充标签的方法。

- (UITableViewCell *)tableView:(UITableView *)tableView
     cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString * CompanyListCellIdentifier =
@"CompanyList";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CompanyListCellIdentifier];
  if (cell == nil) {
    NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"CompanySubscriptionView" owner:self options:nil];
    cell = [topLevelObjects objectAtIndex:0];

}
NSUInteger row = [indexPath row];
CompanyModel *company = [list objectAtIndex:row];

name.text = company.name;
network.text = company.networks;
NSString* subscriptionCountString = [NSString stringWithFormat:@"%d", company.subscriptions.count];
subscriptionCount.text = subscriptionCountString;
fromPrice.text = company.fromPrice;
NSString* trustScoreString = [NSString stringWithFormat:@"%d", company.trustScore];
trustScore.text = trustScoreString;

cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;

}

奇怪的是,在下一个视图中,当按下其中一个单元格时,我没有任何问题使视图填充整个宽度和高度,并且它以完全相同的方式创建(参见下图)。它是xib文件中我做错了还是代码中的东西?

pic3 http://casperslynge.dk/iphone2.png

有人可以帮忙吗?

1 个答案:

答案 0 :(得分:1)

正如我从截图中看到的那样,您尝试使用具有分组样式的表视图,而您肯定需要一个普通的(至少对于第一个视图)。

相关问题