4

UIActionSheetiOS 8 までは非常に単純なピッカーを提示していました。現在、最新のアップデートでその機能が壊れているようです。それはサポートされておらず、ドキュメントではずっと推奨されていませんでした。

おそらく、UIActionSheet機能全体が廃止され、今後サポートされなくなります。ドキュメントには、代わりに UIAlertController を使用するように記載されています。

に切り替えてUIAlertControllerみたところ、最初に予想していたソリューションが、最初に提示したソリューションよりも優れていることがわかりました。

私の元のコード:

// Ask user for project to associate the new issue with a project
        UIActionSheet *menu = [[UIActionSheet alloc] initWithTitle:NSLocalizedString(@"Select Project", @"Title for Action Sheet")
                                                          delegate:self 
                                                 cancelButtonTitle:klocalized_CancelButtonTitle
                                            destructiveButtonTitle:nil 
                                                 otherButtonTitles:klocalized_SelectButtonTitle ,nil];

        [menu addSubview:self.projectPicker];
        [menu showFromTabBar:self.tabBarController.tabBar];
        [menu setBounds:CGRectMake(0, 0, 320, 700)];

iOS 7 では問題なく動作しました。

私の新しいコード。見栄えは良くなりますが、何らかの理由で、プロパティUITextFieldの設定を尊重することができません。inputViewそれは私のテキストフィールドを標準のキーボードで表示します。

新しい、iOS 8 の進行中の作業:

// is iOS 8, ActionSheet, newly deprecated, will not allow subviews. Use UIAlertController instead
        NSString *title = NSLocalizedString(@"Select Project", @"Title for Action Sheet");
        UIAlertController *projectSelector = [UIAlertController alertControllerWithTitle:title message:nil preferredStyle:UIAlertControllerStyleAlert];
        [projectSelector addAction:[UIAlertAction actionWithTitle:klocalized_CancelButtonTitle style:UIAlertActionStyleCancel handler:nil]];
        [projectSelector addAction:[UIAlertAction actionWithTitle:klocalized_SelectButtonTitle style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
            // Do my button action stuff here

        }]];

        [projectSelector addTextFieldWithConfigurationHandler:^(UITextField *textField) {
            // projectField is lazily created property.
            //My picker is set as its inputView but standard keyboard is always presented instead.
            textField = self.projectField;
        }];

        [self presentViewController:projectSelector animated:YES completion:^{
            // Do my final work here

        }];

なぜこれが起こっているのか誰にも教えてもらえますか?inputViewのプロパティは新しいUITextfieldビューでは使用できUIAlertControllerませんか? UIPickerViewこの方法で成功した人はいますか?

projectFieldまたはprojectPickerプロパティのコードは含めていませんが、テストして確認しました。それらは有効なオブジェクトを作成します。ピッカーは提示している VC によって保持され、テキスト フィールドは弱く、AlertViewController によって所有されていると思います。私もそれを保持しようとしましたが、効果はありませんでした。

テキスト フィールドからも Delegate 呼び出しを受け取るUITextFieldので、表示されるのは私が作成したオブジェクトであることがわかります。pickerView を明確に設定したときに標準キーボードが表示される理由は考えられませんinputView

スクリーンショットの結果ビューを参照してください。

UITextField を使用した UIAlertController

4

1 に答える 1