2012-09-05 43 views
0

您好我正在我的應用程序中做一個自定義操作表,我注意到一個小問題。UIActionsheet showinview不從底部的動畫

解僱是正常,但做的時候[actionSheet showInView:self.view],

的actionsheet動畫不從最底層開始。

從滾動到最上方的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)]; 
+0

是't];'是什麼的一部分? –

+0

只是一種類型:)正在刪除不必要的行以更好地關注問題。謝謝 – unpluggedk

回答

0

刪除此行:

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

+0

如果我這樣做,只顯示一小部分的動作表。 – unpluggedk

+0

對不起,我的錯。你正在添加一個選擇器到你不擁有的視圖 - 一個內部的蘋果視圖 - 並期待它的工作(我錯過了)。如果你甚至可以實現這個目標,它可能會在ios6,或者一個發佈版本或者ios 7中崩潰。如果你有這樣的需求,那麼創建你自己的視圖,使之動畫化 - 忘記試圖修改一個你不需要的視圖擁有。 –

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)]; 

一下這個,如果你有任何問題告訴我。