UIAlertViewでUIPickerViewを作成しようとしていますが、次のコードを記述しました
UIAlertView *alert = [[UIAlertView alloc] initWithFrame:CGRectMake(0, 0, 300, 200)];
alert.title = @"Preferences";
alert.message = @"\n\n\n\n\n\n\n";
alert.delegate = self;
[alert addButtonWithTitle:@"Cancel"];
[alert addButtonWithTitle:@"OK"];
UIPickerView *myPickerView = [[UIPickerView alloc] initWithFrame:CGRectZero];
myPickerView.delegate = self;
myPickerView.showsSelectionIndicator = YES;
myPickerView.autoresizingMask = UIAlertViewStyleDefault;
myPickerView.frame = CGRectMake(10, 40, 250, 150);
[alert addSubview:myPickerView];
[alert show];
ただし、実行すると、pickerViewのサイズがアラートビューに適合せず、画像に示されているように見えます。
どうすればこの問題を解決できますか?前もって感謝します。
私はそれを解決しました、私は私が次のコードを持っていることを発見しました
- (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component {
int sectionWidth = 300;
return sectionWidth;
}
これを外すと直りました。:)みんなが私を助けてくれてありがとう、そして私は私の間違いをとても残念に思います。:$