2

したい

  1. ピッカー ビューを表示する (上にスライド)
  2. 背景が表示されている間は背景を無効にします
  3. (UIActionSheet)ボタンを(上部ではなく)下部に表示します

ピッカー ビューをアクション シートに追加するコードは Web のいたるところにありますが、すべてのソリューションはボタンを上部に配置し、アクション シートの下部にボタンを配置する必要があるため、最初は簡単な解決策のように思えます(アライメント?) .

これは可能ですか?私が見ればそれだと思います:

よろしく

ジェブン

EDITED(コード化されたお父さんのソリューションに基づく私のソリューション)

UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil
                                                             delegate:nil
                                                    cancelButtonTitle:nil
                                               destructiveButtonTitle:nil
                                                    otherButtonTitles:nil];
    [actionSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent];

    CGRect pickerFrame = CGRectMake(0, 0, 0, 0);
    UIPickerView *pickerView = [[UIPickerView alloc]initWithFrame:pickerFrame];
    pickerView.showsSelectionIndicator = YES;
    pickerView.dataSource = self;
    pickerView.delegate = self;

    UISegmentedControl *backButton =  [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"Back", nil]] ;
    [backButton addTarget:self action:@selector(someFunction:) forControlEvents:UIControlEventValueChanged];
    backButton.tintColor = [UIColor colorWithRed:0.10 green:0.20 blue:0.52 alpha:0.5];
    backButton.segmentedControlStyle = UISegmentedControlStyleBar;
    [backButton addTarget:self action:@selector(btnActionCancelClicked:) forControlEvents:UIControlEventAllEvents];
    backButton.frame = CGRectMake(20.0, 220.0, 280.0, 40.0);

    UISegmentedControl *acceptButton =  [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"Accept", nil]] ;
    [acceptButton addTarget:self action:@selector(anotherFunction:) forControlEvents:UIControlEventValueChanged];
    acceptButton.tintColor = [UIColor colorWithRed:0.10 green:0.20 blue:0.52 alpha:0.5];
    acceptButton.segmentedControlStyle = UISegmentedControlStyleBar;
    acceptButton.frame = CGRectMake(20.0, 280.0, 280.0, 40.0);

    [actionSheet addSubview:pickerView];
    [actionSheet addSubview:backButton];
    [actionSheet addSubview:acceptButton];

    [actionSheet showInView:[[UIApplication sharedApplication] keyWindow]];
    [actionSheet setFrame:CGRectMake(0,150,320, 400)]; 

...次に、iPhone 5/iPhone 4 に依存するビュー サイズの制約を適用するだけです

EDITED 2: もう一つのヒント!もともと、標準の Actionsheet を使用したかったのですが、ピッカービューを一番下に配置したくありませんでした。ボタンを移動する方法が見つかりませんでした。明らかにそれは本当に簡単です: UIActionSheet の subView として UIView を追加します ;)

4

1 に答える 1