UIPicker和UIActionsheet不再适用于iOS7 [英] UIPicker and UIActionsheet no longer working iOS7
问题描述
Hi My UI Picker不再在iOS7上运行,它会弹出但为空.仅在iOS7上发生过.
Hi My UI Picker no longer works on iOS7, it pops up but it is blank. Only happened on iOS7.
//picker
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{
animationsLabel.text = [optionsArray objectAtIndex:[picker selectedRowInComponent:0]];
if (pickerView==animationsPicker) {
animationsLabel.text = [optionsArray objectAtIndex:[animationsPicker selectedRowInComponent:0]];
}
}
-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{
return 1;
}
-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{
return [optionsArray count];
}
-(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{
return [optionsArray objectAtIndex:row];
NSLog(@"title options array %lu",(unsigned long)optionsArray.count);
}
动作:
-(IBAction)animationActionSheet:(id)sender {
UIActionSheet *selectPopup = [[UIActionSheet alloc] initWithTitle:@"\n\n\n\n\n\n\n\n"
delegate:nil
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:nil];
[selectPopup showInView:self.view];
optionsArray = [[NSMutableArray alloc] initWithObjects:@"1",@"2",@"3",@"4",@"6",@"5",@"7",@"8",@"9", nil];
// Create picker
animationsPicker = [[UIPickerView alloc] initWithFrame:CGRectMake(10, 160, 320, 100)];
animationsPicker.showsSelectionIndicator = YES;
[self.view addSubview:animationsPicker];
animationsPicker.delegate = self;
animationsPicker.dataSource = self;
[selectPopup addSubview:animationsPicker];
// Animate picker opening
[UIView beginAnimations:nil context:nil];
[selectPopup setBounds:CGRectMake(0, 0, 320, 485)];
[UIView commitAnimations];
}
这是我到目前为止尝试过的.以前在动作表中显示选择器从来没有问题,但是现在是空白.我想知道是否还有其他人遇到此问题,或者您能看到任何错误吗?我打印了与选择器有关的所有内容.
This is what I have tried so far. There was never a problem displaying the picker in the an Action sheet before, but now it is blank. Im wondering did anyone else come across this problem, or can you see any errors? I printed everything to do with the picker.
推荐答案
有人告诉我,将选择器放入操作表中是非标准的.我在iOS 6中从未遇到任何问题,但是在iOS 7中,我遇到了错误.我为选择器切换到了UIView而不是操作表,它可以正常工作.我希望这会有所帮助.
I was told that putting pickers in Action Sheets was non-standard. I never had any problems doing this in iOS 6, but in iOS 7, I got errors. I switched to UIView instead of action sheets for my pickers and it works fine. I hope this helps.
这篇关于UIPicker和UIActionsheet不再适用于iOS7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!