Reading from topLayoutGuide causes contentSize to be set to {0,0}
| Originator: | jdelStrother | ||
| Number: | rdar://15208516 | Date Originated: | 2013-10-11 |
| Status: | Open | Resolved: | |
| Product: | iOS SDK | Product Version: | iOS7 |
| Classification: | Severe bug | Reproducible: | Always |
Summary:
If you read from the -[UIViewController topLayoutGuide] property before everything is fully laid out, something causes the contentSize of the controller's view to be set to {0,0}. This then prevents you from being able to scroll properly - in the attached example, you can drag the tableview up, but it springs back into place without letting you see what's below the screen
Steps to Reproduce:
1 - create a UITableViewController in a UINavigationController (the one in the Master-Detail sample code will do)
2 - read from self.topLayoutGuide in awakeFromNib (or viewWillAppear, or viewWillLayoutSubviews, or...)
Expected Results:
Crazy content sizes like {0,0} should not be applied to the scroll view.
Actual Results:
Crazy content sizes like {0,0} are applied to the scroll view.
Version:
iOS 7.0.2
----------------
This is a variant of the Master-Detail sample app that demonstrates the problem :
@implementation ABMasterViewController
- (void)awakeFromNib
{
for(int i=0; i<20; i++) {
[self insertNewObject:nil];
}
(void)self.topLayoutGuide;
[super awakeFromNib];
}
- (void)insertNewObject:(id)sender
{
if (!_objects) {
_objects = [[NSMutableArray alloc] init];
}
[_objects insertObject:[NSDate date] atIndex:0];
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
[self.tableView insertRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
}
#pragma mark - Table View
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return _objects.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
NSDate *object = _objects[indexPath.row];
cell.textLabel.text = [object description];
return cell;
}
@end
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!