プログラムで多くのビューを作成し、デバイスの向きに基づいてサイズを設定したいと考えています。これが私が今やっている方法です:
UIView *view1 = [[UIView alloc] init];
if(UIInterfaceOrientationIsLandscape(self.interfaceOrientation))
view1.frame = CGRectMake (0, 0, 1024, 44);
else
view1.frame = CGRectMake (0, 0, 764, 44);
[self.view addSubview:view1];
しかし、すべてのビューに対してこれを行うのは面倒です。- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation) toInterfaceOrientation duration:(NSTimeInterval)duration
また、メソッドで使用するコードを複製する必要があります。これを行う簡単な方法はありませんか?