次のコードがあります。
- (void)loadView {
[super loadView];
UIScrollView *scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 87, self.view.frame.size.width, self.view.frame.size.height)];
scroll.pagingEnabled = YES;
NSInteger numberOfViews = 2;
scroll.contentSize = CGSizeMake(self.view.frame.size.width * numberOfViews, self.view.frame.size.height);
scroll.autoresizingMask=(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
[self.view addSubview:scroll];
for (int i = 0; i < numberOfViews; i++) {
CGFloat yOrigin = i * self.view.frame.size.width;
UIView *awesomeView = [[UIView alloc] initWithFrame:CGRectMake(yOrigin, 0, self.view.frame.size.width, self.view.frame.size.height)];
[scroll addSubview:awesomeView];
UIButton *myButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
int x=1;
for (int i=0; i<=2; i++) {
for (int z=0; z<=2; z++) {
myButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
myButton.frame = CGRectMake(4+(80*z), 122+(61*i), 72, 53);
NSString *numero=[NSString stringWithFormat:@"%d", x];
x++;
[myButton setTitle:numero forState:UIControlStateNormal];
myButton.titleLabel.font = [UIFont fontWithName:@"System Bold" size:31];
myButton.titleLabel.font = [UIFont boldSystemFontOfSize:31];
[myButton addTarget:self action:@selector(numeros:) forControlEvents:UIControlEventTouchUpInside];
myButton.autoresizingMask=(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
[awesomeView addSubview:myButton];
}
}
}
}
を作成しScrollView
、9 を入れUIButton
ます。
私の問題は: IB を使用して を配置していたUIButton
とき、ボタンは自動的に自動サイズ調整され、iPad ビューに配置されましたが、今では次のようになっています。
何か案は?ありがとう。:D