Search code examples
iosuiactionsheet

UIActionSheet coming up too far from bottom of screen


So for some reason after I've just added an actionsheet it's coming up and stopping above the bottom of the screen. Is there a way to manually tell this where to stop?

- (void)showActionSheet:(UIButton *)standardButton{
    UIActionSheet *popupQuery = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"Cancel Button" destructiveButtonTitle:nil otherButtonTitles:@"Choose From Library", @"Take Photo", nil];
    popupQuery.actionSheetStyle = UIActionSheetStyleAutomatic;
    [popupQuery showInView:self];
}

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
    if (buttonIndex == 0) {
        // Choose from library tapped
        NSLog(@"Choose");
    } else if (buttonIndex == 1) {
        // Take a photo tapped
        NSLog(@"Take");
    } 
}

enter image description here


Solution

  • Try self.view instead of self.