我試圖創建一個UIAlertView中UIPickerView,我寫了下面的代碼調整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;
}
當我刪除了這一點,它固定。 :) 感謝大家試圖幫助我,我很抱歉我的錯誤。 :$
您可以更改選取器視圖的寬度 – Leena 2012-07-31 09:05:31
我試圖減少它,但它會減少右側的「拾取器邊緣」一行,並且其餘選取器會通過警報的邊緣 – user1553381 2012-07-31 09:10:08