0

嗨,我正在我的应用程序中做一个自定义操作表,我注意到一个小问题。

解雇是可以的,但在执行 [actionSheet showInView:self.view] 时,

动作表动画不是从最底部开始的。

它出现在距离底部 200 像素的地方,然后一直向上滚动。

这是一个已知的问题?我将在下面粘贴我的代码。

在进行解雇时,它从顶部到底部的动画非常流畅。

提前感谢您的帮助!

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

    CGRect pickerFrame = CGRectMake(0, 40, 0, 0);
    datePickerView = [[UIDatePicker alloc] initWithFrame:pickerFrame];

    [actionSheet addSubview:datePickerView];

    [actionSheet showInView:self.view];
    [actionSheet setBounds:CGRectMake(0, 0, 320, 480)];
4

2 回答 2

0

这是工作正常的代码。:

 UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"" delegate:nil cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
    actionSheet.backgroundColor = [UIColor clearColor];
    UIImageView *background = [[UIImageView alloc] init];
    [background setBackgroundColor:[UIColor whiteColor]];
    [background setFrame:CGRectMake(0,0, 345, 250)];
    background.contentMode = UIViewContentModeScaleToFill;
    [actionSheet addSubview:background];

    UIButton *cancelButton = [UIButton buttonWithType: UIButtonTypeCustom];
    cancelButton.frame = CGRectMake(5, 160, 320, 100);

    [cancelButton addTarget:self action:@selector(cancelButtonClicked:)forControlEvents:UIControlEventTouchUpInside];
    cancelButton.adjustsImageWhenHighlighted = YES;
    [cancelButton setTitle:@"Cancel" forState:UIControlStateNormal];
    [cancelButton setTitleColor:[UIColor colorWithRed:21/255.0f green:117/255.0f blue:222/255.0f alpha:1.0f] forState:UIControlStateNormal];
    cancelButton.titleLabel.textAlignment = NSTextAlignmentCenter;

    cancelButton.titleLabel.font = [UIFont fontWithName: @"Helvetica Neue" size: 22];

    [actionSheet addSubview: cancelButton];

    UIButton *airdropButton = [UIButton buttonWithType: UIButtonTypeCustom];
    airdropButton.frame = CGRectMake(0,3, 100,80);
    [airdropButton setImage:[UIImage imageNamed:@"airdrop.png"] forState:UIControlStateNormal];

    airdropButton.adjustsImageWhenHighlighted = YES;
    UILabel *line=[[UILabel alloc]initWithFrame:CGRectMake(0,90,345,1)];
    [line setBackgroundColor:[UIColor grayColor]];

    UIButton *messageButton = [UIButton buttonWithType: UIButtonTypeCustom];
    messageButton.frame = CGRectMake(10,95,80,80);
    [messageButton setImage:[UIImage imageNamed:@"message.png"] forState:UIControlStateNormal];

    messageButton.adjustsImageWhenHighlighted = YES;


    UIButton *mailButton = [UIButton buttonWithType: UIButtonTypeCustom];
    mailButton.frame = CGRectMake(80,95,100,80);
    [mailButton setImage:[UIImage imageNamed:@"mail.png"] forState:UIControlStateNormal];
    mailButton.adjustsImageWhenHighlighted = YES;


    UIButton *twitterButton = [UIButton buttonWithType: UIButtonTypeCustom];
    twitterButton.frame = CGRectMake(160,95,80,80);
    [twitterButton setImage:[UIImage imageNamed:@"twitter.png"] forState:UIControlStateNormal];

    twitterButton.adjustsImageWhenHighlighted = YES;

    UIButton *facebookButton = [UIButton buttonWithType: UIButtonTypeCustom];
    facebookButton.frame = CGRectMake(230,95,80,80);
    [facebookButton setImage:[UIImage imageNamed:@"facebook.png"] forState:UIControlStateNormal];

    facebookButton.adjustsImageWhenHighlighted = YES;


    [actionSheet addSubview: airdropButton];
    [actionSheet addSubview:line];
    [actionSheet addSubview:messageButton];
    [actionSheet addSubview:mailButton];
    [actionSheet addSubview:facebookButton];
    [actionSheet addSubview:twitterButton];



    [actionSheet showInView:myProfileTable];
    [actionSheet setFrame:CGRectMake(0,340,345,250)];

看看这个,如果你有任何问题告诉我。

于 2014-11-06T11:47:33.453 回答
0

删除这一行:

[actionSheet setBounds:CGRectMake(0, 0, 320, 480)];

于 2012-09-05T17:59:11.280 回答