これは、以前にUIActionSheetPickerを実際に使用したことがある人にとっては、非常に的を絞った質問になるでしょう。
私はそれを私のiphoneアプリケーションで使用し、すべてがうまく機能しましたが、今私はそれを私のipadに実装しようとしたので、私はいくつかの問題を経験しました。
主な問題は、ipadでは、必要に応じてピッカーが「バブル」または「情報ウィンドウ」として表示されることです。これは、ボタンやテキストフィールドなど、呼び出された場所を指します。
以下はその例です:
「情報ウィンドウ」が動物ボタンを指していることがわかります。
私のアプリケーションでは、4つの異なるボタンがあります。2つは画面の上部にあり、2つは下部にあります。
一番下にいる人は、ピッカーを非常によく呼び出し、ピッカーはそれらを下に向けているボタンの上に表示されます。
ただし、ピッカーを呼び出すと、画面の上部にあるもの(ほとんど画像のように)は、ピッカーが画面のはるかに下に表示され、本来の位置を指していません...
(画像のように)それらを指しているボタンのすぐ下に表示されることを期待していましたが、それらは画面のほぼ中央にあり、どこも指していません。
何か案は?誰かがこれを以前に経験したことがありますか?
編集
最初は、ボタン内のActionSheetPickerを次のように呼び出していました。
- (IBAction)selectTopic:(UIControl *)sender {
[ActionSheetStringPicker showPickerWithTitle:NSLocalizedString(@"CHOOSE_TOPIC", nil) rows:self.topics initialSelection:self.selectedIndex target:self successAction:@selector(topicWasSelected:element:) cancelAction:@selector(actionPickerCancelled:) origin:sender];
//when user picks a new topic we clean the titleField to make sure selected title of previous topic doesnt mix up with new topic
titleField.text = @"";
}
今、私はそれをこのように呼ぼうとしています:
- (IBAction)selectTopic:(UIControl *)sender {
ActionSheetStringPicker *thePicker = [[ActionSheetStringPicker alloc] initWithTitle:NSLocalizedString(@"CHOOSE_TOPIC", nil) rows:self.topics initialSelection:self.selectedIndex target:self successAction:@selector(topicWasSelected:element:) cancelAction:@selector(actionPickerCancelled:) origin:sender];
thePicker.presentFromRect = topicField.frame;
[thePicker showActionSheetPicker];
//when user picks a new topic we clean the titleField to make sure selected title of previous topic doesnt mix up with new topic
titleField.text = @"";
}
ここで、topicFieldは私のTextFieldです。
悲しいことに、結果は同じです。矢印が指す場所を指定しているので、ピッカーは300ピクセル下と呼ばれます。
奇妙なことに、前のボタンよりも少し低い別のボタンを使用しても、ピッカーは再び正確に300ピクセル下になります。
EDIT2
ピッカーが300ピクセル下に表示されていることに気付いた後、ボタンを正確に指すように、手動で300ピクセル上に表示することにしました。
私は次のコードを使用しました:
- (IBAction)selectTopic:(UIControl *)sender {
//[ActionSheetStringPicker showPickerWithTitle:NSLocalizedString(@"CHOOSE_TOPIC", nil) rows:self.topics initialSelection:self.selectedIndex target:self successAction:@selector(topicWasSelected:element:) cancelAction:@selector(actionPickerCancelled:) origin:sender];
ActionSheetStringPicker *thePicker = [[ActionSheetStringPicker alloc] initWithTitle:NSLocalizedString(@"CHOOSE_TOPIC", nil) rows:self.topics initialSelection:self.selectedIndex target:self successAction:@selector(topicWasSelected:element:) cancelAction:@selector(actionPickerCancelled:) origin:sender];
CGRect pickerFrame = topicField.frame;
pickerFrame.size.height -= 300;
thePicker.presentFromRect = pickerFrame;
[thePicker showActionSheetPicker];
//when user picks a new topic we clean the titleField to make sure selected title of previous topic doesnt mix up with new topic
titleField.text = @"";
}
驚くべきことに、ボタンは300ピクセル下の同じ位置に再び表示されます。私はこれがピッカーの位置を変えるための財産ではないかもしれないと信じ始めます。
何か案は ?