iRSSの日記

はてなダイアリーiRSSの日記の続き

willAnimateRotationToInterfaceOrientation直後のview.frameとview.boudsがは向きが異なる?

メモ

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration
{
    NSString *orient;
    switch(interfaceOrientation) {
        case UIInterfaceOrientationLandscapeRight:
            orient = @"UIInterfaceOrientationLandscapeRight";
            break;
        case UIInterfaceOrientationLandscapeLeft:
            orient = @"UIInterfaceOrientationLandscapeLeft";
            break;
        case UIInterfaceOrientationPortrait:
            orient = @"UIInterfaceOrientationPortrait";
            break;
        case UIInterfaceOrientationPortraitUpsideDown:
            orient = @"UIInterfaceOrientationPortraitUpsideDown";
            break;
        default: 
            orient = @"Invalid orientation";
    }
    NSLog(@"willRotateToInterfaceOrientation: %@", orient);
    NSLog(@"self.view.frame:%@",NSStringFromCGRect(self.view.frame));
    NSLog(@"self.view.bounds:%@",NSStringFromCGRect(self.view.bounds));
}

を呼び出したあとの現象
self.view.frameとself.view.boundsは方向が違う

2011-10-17 11:26:41.602 lotaionSample[34834:f803] willRotateToInterfaceOrientation: UIInterfaceOrientationLandscapeLeft
2011-10-17 11:26:41.604 lotaionSample[34834:f803] self.view.frame:{{20, 0}, {300, 480}}
2011-10-17 11:26:41.604 lotaionSample[34834:f803] self.view.bounds:{{0, 0}, {480, 300}}

2011-10-17 11:26:43.182 lotaionSample[34834:f803] willRotateToInterfaceOrientation: UIInterfaceOrientationPortraitUpsideDown
2011-10-17 11:26:43.183 lotaionSample[34834:f803] self.view.frame:{{0, 0}, {320, 460}}
2011-10-17 11:26:43.195 lotaionSample[34834:f803] self.view.bounds:{{0, 0}, {320, 460}}

2011-10-17 11:26:44.460 lotaionSample[34834:f803] willRotateToInterfaceOrientation: UIInterfaceOrientationLandscapeRight
2011-10-17 11:26:44.460 lotaionSample[34834:f803] self.view.frame:{{0, 0}, {300, 480}}
2011-10-17 11:26:44.468 lotaionSample[34834:f803] self.view.bounds:{{0, 0}, {480, 300}}

2011-10-17 11:26:45.252 lotaionSample[34834:f803] willRotateToInterfaceOrientation: UIInterfaceOrientationPortrait
2011-10-17 11:26:45.253 lotaionSample[34834:f803] self.view.frame:{{0, 20}, {320, 460}}
2011-10-17 11:26:45.258 lotaionSample[34834:f803] self.view.bounds:{{0, 0}, {320, 460}}

willRotateToInterfaceOrientation,didRotateFromInterfaceOrientationでも値は同じ

2011-10-17 11:29:37.769 lotaionSample[34874:f803] willRotateToInterfaceOrientation: UIInterfaceOrientationLandscapeLeft
2011-10-17 11:29:37.771 lotaionSample[34874:f803] self.view.frame:{{20, 0}, {300, 480}}
2011-10-17 11:29:37.771 lotaionSample[34874:f803] self.view.bounds:{{0, 0}, {480, 300}}
2011-10-17 11:29:38.073 lotaionSample[34874:f803] didRotateFromInterfaceOrientation: UIInterfaceOrientationPortrait
2011-10-17 11:29:38.073 lotaionSample[34874:f803] self.view.frame:{{20, 0}, {300, 480}}
2011-10-17 11:29:38.074 lotaionSample[34874:f803] self.view.bounds:{{0, 0}, {480, 300}}

2011-10-17 11:29:44.494 lotaionSample[34874:f803] willRotateToInterfaceOrientation: UIInterfaceOrientationPortraitUpsideDown
2011-10-17 11:29:44.495 lotaionSample[34874:f803] self.view.frame:{{0, 0}, {320, 460}}
2011-10-17 11:29:44.495 lotaionSample[34874:f803] self.view.bounds:{{0, 0}, {320, 460}}
2011-10-17 11:29:44.798 lotaionSample[34874:f803] didRotateFromInterfaceOrientation: UIInterfaceOrientationLandscapeLeft
2011-10-17 11:29:44.798 lotaionSample[34874:f803] self.view.frame:{{0, 0}, {320, 460}}
2011-10-17 11:29:44.799 lotaionSample[34874:f803] self.view.bounds:{{0, 0}, {320, 460}}

2011-10-17 11:29:52.168 lotaionSample[34874:f803] willRotateToInterfaceOrientation: UIInterfaceOrientationLandscapeRight
2011-10-17 11:29:52.169 lotaionSample[34874:f803] self.view.frame:{{0, 0}, {300, 480}}
2011-10-17 11:29:52.170 lotaionSample[34874:f803] self.view.bounds:{{0, 0}, {480, 300}}
2011-10-17 11:29:52.470 lotaionSample[34874:f803] didRotateFromInterfaceOrientation: UIInterfaceOrientationPortraitUpsideDown
2011-10-17 11:29:52.471 lotaionSample[34874:f803] self.view.frame:{{0, 0}, {300, 480}}
2011-10-17 11:29:52.472 lotaionSample[34874:f803] self.view.bounds:{{0, 0}, {480, 300}}

2011-10-17 11:29:53.070 lotaionSample[34874:f803] willRotateToInterfaceOrientation: UIInterfaceOrientationPortrait
2011-10-17 11:29:53.070 lotaionSample[34874:f803] self.view.frame:{{0, 20}, {320, 460}}
2011-10-17 11:29:53.071 lotaionSample[34874:f803] self.view.bounds:{{0, 0}, {320, 460}}
2011-10-17 11:29:53.372 lotaionSample[34874:f803] didRotateFromInterfaceOrientation: UIInterfaceOrientationLandscapeRight
2011-10-17 11:29:53.373 lotaionSample[34874:f803] self.view.frame:{{0, 20}, {320, 460}}
2011-10-17 11:29:53.373 lotaionSample[34874:f803] self.view.bounds:{{0, 0}, {320, 460}}

boundsを見れば大丈夫そうだけど、frameって向きが関係ないということか。
これまでも、そうだったっけ?

検証したソース
http://rss.rdy.jp/iRSS_sample/lotaionSample.zip