向きが変更されたときに UINavigationBar titleview コンテンツ イメージのサイズを変更する最良の方法は何ですか。高さ44pxの画像と32pxの画像があり、ビューを回転させた後、タイトルビューを変更して新しい画像ビューを設定します。しかし、マスクの自動サイズ変更やその他のトリックによって何らかの結果を達成する別の方法があるのではないでしょうか?
1 に答える
1
autoresizingMask は、デバイスが回転したときにビューのフレームのサイズを変更できますが、回転が発生したときに 2 つの異なる画像を切り替えたい場合は、プログラムでそれを行う必要があります。willAnimateRotationToInterfaceOrientation:duration:
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration
{
[super willAnimateRotationToInterfaceOrientation:interfaceOrientation duration:duration];
if (interfaceOrientation == UIDeviceOrientationLandscapeRight || interfaceOrientation == UIDeviceOrientationLandscapeLeft) {
// landscape
[imageView setImage:landscapeImage];
} else {
// portrait
[imageView setImage:portraitImage];
}
}
于 2012-04-26T14:50:28.103 に答える