自動サイズ変更に関する多くの情報を見つけましたが、私の問題を解決できたものはありません。次のように、loadView メソッドでビューを呼び出す ViewController (RAViewController) があります。
- (void)loadView
{
// Set Navigation Bar Title
self.navigationItem.title = @"RA";
// Add Background view
self.view = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Add RAView
RAView *rAView = [[RAView alloc] initWithFrame:self.view.frame Controller:self];
[self.view rAView];
}
それが呼び出すビュー (RAView) は次のようになります。
- (id)initWithFrame:(CGRect)frame Controller:(RAViewController *)Controller
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
self.autoresizesSubviews = YES;
self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.backgroundColor = [[UIColor alloc] initWithRed:1.0 green:1.0 blue:1.0 alpha:1.0];
controller = Controller;
// Draw Architecture View
[self drawArchitectureView];
}
return self;
}
-(void)drawArchitectureView {
UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(10, 10, self.frame.size.width - 20, 50);
[button setBackgroundColor:[UIColor grayColor]];
[button setTitle:@"Overview" forState:UIControlStateNormal];
[self addSubview:button];
}
何らかの理由で、デバイスが横向きの場合、自動サイズ変更マスクを使用してボタンの幅をサイズ変更できません。どんな助けでも大歓迎です。