简体   繁体   中英

Action sheet loads for 1st time with an space from the bottom of the screen?

Action Sheet shows an space of height 20 to 30 pixels when the action sheet loads for the 1st time. When I load the action sheet for the second time it loads properly.

- (void)viewDidLoad { 
    [super viewDidLoad]; 
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackOpaque animated:YES]; 
    [self loadImage:nil]; 
} 

When the view load, I am calling the above event which is showing the space at the bottom of the page.

And when I load it from the following function it is working fine.

- (IBAction)loadImage:(id)sender { 
    if(!actionSheetAction) { 
        UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"" 
                                                                 delegate:self 
                                                        cancelButtonTitle:@"Cancel"     
                                                   destructiveButtonTitle:nil 
                                                        otherButtonTitles:@"Use Photo from Library", 
                                                                          @"Take Photo with Camera", nil]; 
        actionSheet.actionSheetStyle = UIActionSheetStyleDefault; 
        actionSheetAction = ActionSheetToSelectTypeOfSource; 
        [actionSheet showInView:self.view]; 
        [actionSheet release]; 
    } 
}

When you set UIStatusBarStyleBlackOpaque style of status bar or Navigationbar style with opaque(dont know it's name exactly) then your view will start from Y zero means it's origin Y=0 in case of other style of status bar without opaque Y will be Y=20. May be this will help you.And in case of navigation bar style without opaque you'r origin Y will be 44 and if you have set any Navigation bar type with Opaque then YOur Y will 0(Y=0). Thanks.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM