0

UIActionSheet で UIPickerView を表示しようとしています。以下のコードから、ポートレートモードではうまく機能しますが、ランドスケープモードでは有線に見えます. (私のアプリは iPhone 4/5 n の横向きもサポートしています)。私は何を間違っていますか?

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

    [actionSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent];


    CGRect pickerFrame=CGRectMake(0, 40, 0, 0);

    UIPickerView *pickerView = [[UIPickerView alloc] initWithFrame:pickerFrame];
    pickerView.showsSelectionIndicator = YES;
    pickerView.dataSource = self;
    pickerView.delegate = self;


    [actionSheet addSubview:pickerView];

    UISegmentedControl *closeButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:@"OK"]];
    closeButton.momentary = YES;
    closeButton.frame = CGRectMake(260, 7.0f, 50.0f, 30.0f);
    closeButton.segmentedControlStyle = UISegmentedControlStyleBar;
    closeButton.tintColor = [UIColor blackColor];
    [closeButton addTarget:self action:@selector(dismissActionSheet:) forControlEvents:UIControlEventValueChanged];

    [actionSheet addSubview:closeButton];
    [actionSheet showInView:self.view];
    [actionSheet setBounds:CGRectMake(0, 0, 320, 485)];

ここに画像の説明を入力

4

1 に答える 1

1

最後に私は解決策を得ました

まず、前述のようにピッカー ビューの幅を設定する必要があります。

CGRect pickerFrame=CGRectMake(0, 40, 0, 0);

だからそれはのようにすることができます

CGRect pickerFrame=CGRectMake(0, 40, 320, 0);

もう1つの良い解決策を見つけました:

テキスト フィールドをクリックして、アクション シートでピッカー ビューを呼び出すだけです。

self.textField.inputView = yourCustomView;
于 2013-08-12T07:16:32.300 に答える