Xcode 5.1.1的更新改变了我的表视图行为



我在Xcode 4.6中工作,并设置了一个基本的UItableview,其中从数组填充单元格。在4.6中工作时,视图表现得很好,这正是我喜欢的。在更新到5.1.1之后,表视图上似乎启用了滚动,表视图是从视图的底部加载的,顶部填充的3个单元格不可见。有时视图会橡皮筋,不允许我一直滚动到顶部,有时它不会橡皮筋,会允许我。我对此相当陌生,但尝试过打乱自动布局,但无济于事。

- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
    // Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];

_Manufacturers = @[@"1",
                   @"2",
                   @"3"];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return _Manufacturers.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath       *)indexPath
{
static NSString *CellIdentifier = @"TableCell";
TableCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
// Configure the cell...
int row = [indexPath row];
cell.TitleLabel.text = _Manufacturers[row];

return cell;
}

UITableView在Xcode 4.6中工作的代码应该在Xcode 5.1.1中完美工作。我观察到的主要变化是表格在状态栏下移动。这可以通过以下片段来修复:

self.edgesForExtendedLayout=UIRectEdgeNone;
self.extendedLayoutIncludesOpaqueBars=NO;
self.automaticallyAdjustsScrollViewInsets=NO;

但是,提供代码,这样我就可以了解发生了什么。

最新更新