Thursday, March 31, 2011

Beware Using [UIScreen mainScreen].bounds

Found and fixed another device rotation defect, was using wrong bounds to check screen size. Should have used self.tableView instead of [UIScreen mainScreen]:
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
  NSLog(@"tableView FRAME %.0fx%.0f at %.0fx%.0f",
    self.tableView.frame.size.width,
    self.tableView.frame.size.height,
    self.tableView.frame.origin.x,
    self.tableView.frame.origin.y);
  NSLog(@"tableView BOUNDS %.0fx%.0f at %.0fx%.0f",
    self.tableView.bounds.size.width,
    self.tableView.bounds.size.height,
    self.tableView.bounds.origin.x,
    self.tableView.bounds.origin.y);
  NSLog(@"mainScreen BOUNDS %.0fx%.0f at %.0fx%.0f",
    [UIScreen mainScreen].bounds.size.width,
    [UIScreen mainScreen].bounds.size.height,
    [UIScreen mainScreen].bounds.origin.x,
    [UIScreen mainScreen].bounds.origin.y);
}
Output in landscape orientation:
2011-03-31 07:04:12.789 MyApp[66400:207] tableView FRAME 480x268 at 0x0
2011-03-31 07:04:12.790 MyApp[66400:207] tableView BOUNDS 480x268 at 0x0
2011-03-31 07:04:12.791 MyApp[66400:207] mainScreen BOUNDS 320x480 at 0x0
Getting dangerously close to a releasable state with TWO of my unreleased applications at the same time! Guess I have to start relying on feature creep? No wait, maybe I could start procrastinating with a brand NEW application...

Btw just love this quote:
Only Robinson Crusoe had everything done by Friday.
~Author Unknown

No comments:

Post a Comment