iOS 5 Master-Detail模板Bug?应用程序在键盘打开后纵向设备旋转后具有负底部内容插入

时间:2012-01-21 21:19:49

标签: ios rotation master-detail

以下是如何在Xcode 4.2.1中重现这种奇怪的行为:

(1)使用内置的主 - 细节模板为iOS 5创建一个新的iPad应用程序。确保选中“使用ARC”和“使用故事板”。

(2)在故事板中,将UITextView添加到详细视图控制器中的UIView,就在“详细信息视图内容到达此处”标签下方。

(3)同样在故事板中,选择Master的UITableView,在Attributes Inspector中,将Content设置为“Dynamic Prototypes”。

(4)再次在故事板中,选择Master的UITableview原型单元格,在Attributes Inspector中,将Style设置为“Basic”,将Identifier设置为“CellIdentifier”。

(5)对于Master View Controller实现(MasterViewController.m),添加以下代码:

// show only one section in the master table view
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

// show 30 rows in the master table view
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 30;
}

// when showing a cell, include it's indexPath row in its title text
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    // dequeue cell
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CellIdentifier"];
    // set text
    cell.textLabel.text = [NSString stringWithFormat:@"Row at Index %i", indexPath.row];
    // return cell
    return cell;
}

(6a)运行应用程序。以纵向打开它,然后在详细视图中创建的文本框(UITextView)内单击。键盘将打开。现在将设备向左旋转为横向。

(6b)如果在键盘打开的情况下滚动主视图,您将看到主视图允许您滚动到底行(参见下面的屏幕截图)。这是因为设备自动将Master的UITableView Bottom ContentInset设置为-608。关闭键盘会让它消失。

截图:

enter image description here

最后一点说明:如果您在应用程序中注册设备轮换通知,并在设备旋转后将内容插入设置为UIEdgeInsetsZero,则仍然无法正常工作:设备轮换后,系统仍然具有0底部插图; -608在此之后神秘地被设定了。

0 个答案:

没有答案