繁体   English   中英

UIPicker和UIActionsheet不再适用于iOS7

[英]UIPicker and UIActionsheet no longer working iOS7

Hi My UI Picker不再在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];
}

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

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

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

“子类化Notes UIActionSheet并非旨在进行子类化,也不应在其层次结构中添加视图。如果您需要呈现的工作表比UIActionSheet API提供的自定义项更多,则可以创建自己的工作表并使用presentViewController:animated方式呈现它:completion:。”

苹果正在加强其对Action Sheets的使用...。他们为此增加了赌注,以便在iOS 7中正常工作,这意味着您必须对其进行编码。

看看我做的这个项目。 这实际上与在操作表中放置一个选择器https://github.com/DiscoverPioneer/PickerSlider一样

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM