aがタップされたUIPickerView
ときにビューに a を追加しています。を単独でUILabel
追加していたときは、正常に機能しました。UIPickerView
static const CGFloat HMCMeasurePickerHeight = 200.0;
CGRect measurePickerFrame = CGRectMake(0.0,
CGRectGetHeight(self.view.window.bounds) - HMCMeasurePickerHeight,
CGRectGetWidth(self.view.window.bounds),
HMCMeasurePickerHeight);
UIPickerView *picker = [[UIPickerView alloc] initWithFrame:measurePickerFrame];
picker.dataSource = self;
picker.delegate = self;
picker.showsSelectionIndicator = YES;
[self.view addSubview:picker];
ただし、ツールバーが必要だったので、次のようにラップしましたUIView
。
static const CGFloat HMCMeasurePickerAccessoryHeight = 44.0;
static const CGFloat HMCMeasurePickerHeight = 200.0;
CGRect measurePickerSuperviewFrame = CGRectMake(0.0,
CGRectGetHeight(self.view.window.bounds) - HMCMeasurePickerHeight - HMCMeasurePickerAccessoryHeight,
CGRectGetWidth(self.view.window.bounds),
HMCMeasurePickerAccessoryHeight);
UIView *measurePicker = [[UIView alloc] initWithFrame:measurePickerSuperviewFrame];
CGRect measurePickerAccessoryFrame = CGRectMake(0.0,
0.0,
CGRectGetWidth(self.view.window.bounds),
HMCMeasurePickerAccessoryHeight);
UIToolbar *measurePickerAccessory = [[UIToolbar alloc] initWithFrame:measurePickerAccessoryFrame];
measurePickerAccessory.barStyle = UIBarStyleBlackTranslucent;
UIBarButtonItem *rightAlignSpacer = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace
target:nil
action:nil];
UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone
target:self
action:@selector(dismissMeasurePicker:)];
measurePickerAccessory.items = @[rightAlignSpacer, doneButton];
[measurePicker addSubview:measurePickerAccessory];
CGRect measurePickerFrame = CGRectMake(0.0,
HMCMeasurePickerAccessoryHeight,
CGRectGetWidth(self.view.window.bounds),
HMCMeasurePickerHeight);
UIPickerView *picker = [[UIPickerView alloc] initWithFrame:measurePickerFrame];
picker.dataSource = self;
picker.delegate = self;
picker.showsSelectionIndicator = YES;
[measurePicker addSubview:picker];
[self.view addSubview:measurePicker];
今、スクロールしようとしてUIPickerView
も何も起こりません。追加した [完了] ボタンを正常にタップできますが、UIPickerView
応答していないだけです。設定picker.userInteractionEnabled = YES
してみましたが、効果はありませんでした(最初の例では、デフォルトのように見えYES
ます)。