2013-05-15 46 views
0

我一直在研究一个包含ECSlidingViewController项目的应用程序,使我可以从左侧滑入导航。导航链接是在一个NSArray并使用下面的代码段动态地显示成UITable:调整UITable /单元格宽度

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    NSString *cellIdentifier = @"MenuItemCell"; 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; 
      cell.contentView.backgroundColor=[UIColor blueColor]; 
    if (cell == nil) { 
     cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier]; 
    } 

    cell.textLabel.text = [self.menuItems objectAtIndex:indexPath.row]; 

    return cell; 
} 

的问题是,该文本是太长的长度来显示,一旦我们查看出控制器的幻灯片。现在看起来是这样的:

enter image description here

我很想能够减少单元格的宽度,如果这是可能的,甚至是文本拆分成两行,使它看起来更像是这样的:

enter image description here

任何有用的建议将不胜感激!

回答

1

我最近有完全相同的情况(尽管我使用的是ViewDeck而不是EDSlidingViewController)。

我的解决办法。如果你正在使用ECSlidingViewController版本2(iOS版7+),你可以做到这一点通过在设置edgesForExtendedLayout通过代替其他的UIView中嵌入它改变了整个的UITableView的宽度......

+0

此作品在一定程度上...我可以调整新UITableView,尽管我的表不再由我的NSArray填充。有任何想法吗? –

+0

你需要确保UITableView的数据源和委托仍然适当设置我猜? –