0

在 iPhone 上,我喜欢操作表占据整个屏幕宽度的方式,并且您可以选择它的高度(这样我就可以包含其他视图)。这是我创建动作视图的整个方法(尽管您可能需要最后几行)...

-(void)createActionView {
    UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil 
                                                             delegate:self
                                                    cancelButtonTitle:nil
                                               destructiveButtonTitle:nil
                                                    otherButtonTitles:@"Done",nil];

    [actionSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent];

    UIButton *downHoleScore = [UIButton buttonWithType:UIButtonTypeCustom];
    downHoleScore.frame = CGRectMake(93, 75, 35, 35);
    [downHoleScore setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    downHoleScore.backgroundColor = [UIColor clearColor];
    downHoleScore.tag=1;
    [downHoleScore addTarget:self action:@selector(HoleScoreButtonTap:) forControlEvents:UIControlEventTouchUpInside];
    [downHoleScore setBackgroundImage:[UIImage imageNamed:@"Left-Down-Arrow.png"] forState:UIControlStateNormal];
    [actionSheet addSubview:downHoleScore];

    UIButton *upHoleScore = [UIButton buttonWithType:UIButtonTypeCustom];
    upHoleScore.frame = CGRectMake(193, 76, 35, 35);
    [upHoleScore setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    upHoleScore.backgroundColor = [UIColor clearColor];
    upHoleScore.tag=2;
    [upHoleScore addTarget:self action:@selector(HoleScoreButtonTap:) forControlEvents:UIControlEventTouchUpInside];
    [upHoleScore setBackgroundImage:[UIImage imageNamed:@"Right-Up-Arrow.png"] forState:UIControlStateNormal];
    [actionSheet addSubview:upHoleScore];

    golferScoreLabel = [[UILabel alloc] initWithFrame:CGRectMake(140, 70, 45, 45)];
    golferScoreLabel.text = @"0";
    golferScoreLabel.backgroundColor = [UIColor clearColor];
    golferScoreLabel.font = [UIFont fontWithName:@"ChalkDuster" size: 45.0];
    golferScoreLabel.textAlignment = UITextAlignmentCenter;
    golferScoreLabel.shadowColor = [UIColor grayColor];
    golferScoreLabel.shadowOffset = CGSizeMake(1,1);
    golferScoreLabel.textColor = [UIColor whiteColor];
    [actionSheet addSubview:golferScoreLabel];

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

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

    [actionSheet addSubview:pickerView];

    [actionSheet showInView:[[UIApplication sharedApplication] keyWindow]];

    [actionSheet showFromRect:CGRectMake(0, 0, 320, 585) inView:self.view animated:YES];
}

我将如何编辑它以使其看起来更像 iPhone 上的操作视图?

在这段代码...

[actionSheet showFromRect:CGRectMake(0, 0, 320, 585) inView:self.view animated:YES];

以上是我认为我搞砸的地方,如何让它覆盖 iPad 屏幕的整个下半部分?

4

1 回答 1

0

阅读 上的文档UIActionSheet。在 iPad 上,它们以弹出框的形式呈现。

如果你想要 iPhone 上的行为,我认为你必须编写自己的类似 actionSheet 的视图和动画(这真的不难,只是需要一点时间)。

无论如何,在 iPad 上以全宽呈现 actionSheets 无论如何都不是很好的设计——您可能不希望按钮与整个屏幕一样宽。我建议你重新考虑你的设计。

但也许你真的不想要 actionSheets。也许你只想要那个漂亮的动画,像那样呈现一些你自己的内容?这当然是可行的(见上文),但是你问错了问题。

于 2012-05-06T15:00:38.410 回答