0

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];
}

これは私がこれまでに試したことです。以前はアクション シートにピッカーを表示する際に問題はありませんでしたが、現在は空白になっています。他の誰かがこの問題に遭遇したのでしょうか、それともエラーが表示されますか? ピッカーに関係するすべてを印刷しました。

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 に答える