0
我有一個橫向視圖和一個肖像視圖,作爲包裝視圖的子視圖加載主視圖。橫向視圖和縱向視圖都具有鏈接到它們的UIPickerView對象。在我的源文件中,我將它們全部作爲屬性,並且還爲景觀和肖像拾取器提供了包裝。他們被定義爲UIPickerView不返回正確的數據
@property (nonatomic, retain, readonly) IBOutlet UIPickerView *pickerTown;
@property (nonatomic, retain, readonly) IBOutlet UIPickerView *pickerType;
@property (nonatomic, retain, readonly) IBOutlet UIDatePicker *pickerFrom;
@property (nonatomic, retain, readonly) IBOutlet UIDatePicker *pickerTo;
@property (nonatomic, retain) IBOutlet UIPickerView *landscapePickerTown;
@property (nonatomic, retain) IBOutlet UIPickerView *landscapePickerType;
@property (nonatomic, retain) IBOutlet UIDatePicker *landscapePickerFrom;
@property (nonatomic, retain) IBOutlet UIDatePicker *landscapePickerTo;
@property (nonatomic, retain) IBOutlet UIPickerView *portraitPickerTown;
@property (nonatomic, retain) IBOutlet UIPickerView *portraitPickerType;
@property (nonatomic, retain) IBOutlet UIDatePicker *portraitPickerFrom;
@property (nonatomic, retain) IBOutlet UIDatePicker *portraitPickerTo;
和每個只讀包裝的我有
- (UIPickerView *) pickerTown
{
if(self.landscapeView.superview)
{
return landscapePickerTown;
}else
{
return portraitPickerTown;
}
}
但是,當我在肖像或風景,我試着例如說
myHelper.selectedTown = [myHelper.towns objectAtIndex:[pickerTown selectedRowInComponent:0]];
我沒有得到選定的值,而只是數組中的第一個值。
的數據被添加如下:
if(pickerView == landscapePickerType || pickerView == portraitPickerType) {
return [myHelper.types objectAtIndex:row];
}else if(pickerView == landscapePickerTown || pickerView == portraitPickerTown){
return [myHelper.towns objectAtIndex:row];
}else
{
return @"";
}
和數組:
myHelper = [Helper sharedManager];
[myHelper.types addObject:@"None"];
[myHelper.types addObject:@"Food & Wine"];
[myHelper.types addObject:@"Test"];
[myHelper.towns addObject:@"None"];
[myHelper.towns addObject:@"Vanderbijlpark"];
[myHelper.towns addObject:@"Test"];
什麼我錯在這裏做什麼?
作品謝謝 – Armand