UIActionsheet showinview不是从底部动画

时间:2012-09-05 16:00:02

标签: iphone ios4

您好我正在我的应用程序中执行自定义操作表,并且我注意到一个小问题。

解雇是可以的,但在执行[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)];

2 个答案:

答案 0 :(得分:0)

删除此行:

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

答案 1 :(得分: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)];

如果你有任何问题请调查一下。