【发布时间】:2014-10-17 06:28:33
【问题描述】:
UIPickerView 在 IOS 8 中不工作但它在 IOS 7 中工作没有错误,这是我的代码 一个名为 myArray 的数组在 pickerview 中加载数据
- (void)viewDidLoad
{
[sliderView addSubview:_myPickerView];
txtstreet.inputView=_myPickerView;
myArray = arrwithdata;
}
- (NSInteger)numberOfComponentsInPickerView: (UIPickerView *)pickerView
{
return 1;
}
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
return [myArray count];
}
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)rowForComponent:(NSInteger)component
{
return myArray[row];
}
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row
inComponent:(NSInteger)component
{
NSString *resultString = [[NSString alloc] initWithFormat:@"%@", myArray[row]];
txtstreet.text = resultString;
}
它在 ios7 中运行 这是在 IOS 8 设备中运行时出现的错误
2014-10-17 11:54:19.284 DispatchMe[2119:903697] *** Terminating app due to uncaught
exception 'UIViewControllerHierarchyInconsistency', reason: 'child view controller:
<UICompatibilityInputViewController: 0x145553dc0> should have parent view controller:
<RegistrationVC: 0x14560e930> but requested parent is:<UIInputWindowController:
0x146037a00>'
*** First throw call stack:
(0x183e8e084 0x19446c0e4 0x183e8dfc4 0x1886aa688 0x188d09e14 0x188d0a968 0x18861e77c
0x188d0a794 0x188d06924 0x1886d2180 0x188691b3c 0x188691e10 0x1887114e8 0x1887c2288 0x1887c18f0 0x1887a7768 0x188640184 0x188aa8f78 0x18860475c 0x188602b08 0x18863e32c 0x18863d9cc 0x1886111d4 0x1888af98c 0x18860f73c 0x183e46324 0x183e455c8 0x183e43678 0x183d71664 0x18ceb35a4 0x1886764f8 0x100058068 0x194adaa08)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
【问题讨论】:
-
您是否使用 Actionsheet 来显示 Picker?
-
不,只显示选取器视图
标签: ios iphone ios7 ios8 uipickerview