2015-09-04 82 views
1

我有一个UITableView加载罚款在模拟器和除iPhone 4s以外的所有设备。我一直在寻找答案,甚至暂时搁置,直到现在,我希望能够想到一个解决方案,但似乎没有任何工作。UITableView看起来正确的模拟器和错误的实际设备 - iPhone 4s

我尝试的解决方案是删除可能存在冲突的代码,现在将其评论如下。

// Remove seperator inset 
if ([cell respondsToSelector:@selector(setSeparatorInset:)]) { 
    //[cell setSeparatorInset:UIEdgeInsetsZero]; 
} 

// Prevent the cell from inheriting the Table View's margin settings 
if ([cell respondsToSelector:@selector(setPreservesSuperviewLayoutMargins:)]) { 
    //[cell setPreservesSuperviewLayoutMargins:NO]; 
} 

// Explictly set your cell's layout margins 
if ([cell respondsToSelector:@selector(setLayoutMargins:)]) { 
    //[cell setLayoutMargins:UIEdgeInsetsZero]; 
} 

我当前的代码看起来像这样

- (int)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 
    return 4; 
} 

-(double) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { 
    if (indexPath.row == 3) { 
     return 700.0; 
    } 
    return 44.0; 
} 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    if (indexPath.row == 3) { 
     static NSString *homeTableIdentifier = @"GeneralInfoTableViewCell"; 

     GeneralInfoTableViewCell *cell = (GeneralInfoTableViewCell *)[tableView dequeueReusableCellWithIdentifier:homeTableIdentifier]; 
     if (cell == nil) 
     { 
      NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"GeneralInfoTableViewCell" owner:self options:nil]; 
      cell = [nib objectAtIndex:0]; 
     } 
     cell.selectionStyle = UITableViewCellSelectionStyleNone; 
     return cell; 
    } else if (indexPath.row == 2) { 
... 

请注意,我编辑了这两次显示了在该视图这就是为什么“erbjudanden”在下面的错误观点被切断的标志。

这就是iPhone 4s模拟器中视图的样子(正确的方法)。

enter image description here

这就是视图看起来像在实际的iPhone 4S(错误的方式)

enter image description here

我能做些什么来解决这个问题?

+1

我认为这是细胞的高度问题。您需要增加高度 – Misha

+0

什么是您的设备和模拟器的ios版本? –

+0

@Misha你可以解释这将如何帮助,如果我应该增加单元格的高度或在heightForRowAtIndexPath中返回的数字?所有单元格的高度都是44,除了700以外。这些都是自定义和非常基本的tableview单元格,它们的高度定义为44,除了700之外。谢谢! – Matkey

回答

0

我在这里有问题,因为我的设备运行的是iOS 10,而我的模拟器运行的是iOS 9.3。

我怀疑视图层次调用发生的顺序稍有不同,导致两者之间的显示不同。

在更新所需视图之前致电view.layoutIfNeeded()帮助我解决了问题。

相关问题