0

嗨,我的 UI 选择器不再适用于 iOS7,它会弹出但它是空白的。只发生在 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];
}

这是我到目前为止所尝试的。以前在操作表中显示选择器从来没有问题,但现在它是空白的。我想知道有没有其他人遇到过这个问题,或者你能看到任何错误吗?我打印了与选择器有关的所有内容。

4

3 回答 3

5

有人告诉我,将选择器放入操作表是不标准的。我在 iOS 6 中执行此操作从未遇到任何问题,但在 iOS 7 中,我遇到了错误。我切换到 UIView 而不是我的选择器的操作表,它工作正常。我希望这有帮助。

于 2013-10-01T21:19:01.513 回答
2

根据文档,不建议为操作表添加子视图。

“子类化注意事项 UIActionSheet 不是为子类化而设计的,也不应将视图添加到其层次结构中。如果您需要呈现比 UIActionSheet API 提供的自定义更多的表单,您可以创建自己的表单并使用 presentViewController:animated 以模态方式呈现:完成:。”

Apple 正在加强他们对 Action Sheets 的使用......并且他们提高了在 iOS 7 中工作的赌注,这意味着你必须围绕它编写代码。

于 2013-10-27T10:01:46.137 回答
0

看看我做的这个项目。这实际上与在操作表中使用选择器https://github.com/DiscoverPioneer/PickerSlider相同

于 2014-07-09T21:40:44.937 回答