【发布时间】:2014-12-17 15:32:53
【问题描述】:
当表格的记录多于屏幕让您看到的记录,并且用户滚动到底部以查看表格中的最后一条记录时,最后两行无法访问(仅在 iOS7 中,在 iOS8 中一切都很好)。一旦用户将手指从屏幕上移开,表格就会上升,最后两行被隐藏。
这是用于 tableView 的方法之一,但我不知道这是否来自这里:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString * cellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath];
// Configure the cell...
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}
if (selectionCategMsg == 0)
{
if ([self.tableauMsgReceived count] < 1) {
cell.textLabel.text = NSLocalizedString(@"noMessagesYet", nil); //@"No messages yet !";
}
else
{
cell.textLabel.text = [NSString stringWithFormat:@"%@", [self.tableauMsgReceived objectAtIndex:indexPath.row]];
cell.textLabel.lineBreakMode = NSLineBreakByWordWrapping;
}
}
else
{
if ([self.tableauMsgSent count] < 1) {
cell.textLabel.text = NSLocalizedString(@"noReplyYet", nil);
}
else
{
cell.textLabel.text = [NSString stringWithUTF8String:[NSString stringWithFormat:@"%@", [self.tableauMsgSent objectAtIndex:indexPath.row]].UTF8String];
cell.textLabel.lineBreakMode = NSLineBreakByWordWrapping;
}
}
[cell setAccessoryType:UITableViewCellAccessoryNone];
return cell;
}
有人可以给个建议吗?谢谢你。
这是我找到的解决方案:
// -> SET TABLE FRAME
CGFloat sideMargin = 0;
CGFloat originX = sideMargin;
CGFloat topBottomMargin = 100;
CGFloat originY = topBottomMargin;
// Width based on view size
CGFloat sizeWidth = self.view.bounds.size.width);
// Height based on view size
CGFloat sizeHeight = (self.view.bounds.size.height - topBottomMargin);
self.myTableView.frame = CGRectMake(originX, originY, sizeWidth, sizeHeight);
// <- END SET tableView frame
【问题讨论】:
-
tableView 有错误的边界并超出屏幕...视图有错误的框架。显示您创建表和/或 xib 的代码
-
并删除所有不相关的代码
标签: ios objective-c xcode