Search code examples
iosobjective-cuiactionsheetuialertcontroller

UIAlertController height difference


I have used UIAlertController for actionsheet,please look the images no.1 is old project and no.2 is new one which i have created newly. why the action sheet height is too differ?

This is my code for both app which i'm using. what's wrong on this?. Both deployment target are same. Old project is developed in Xcode 5.1.1 and new one in developed in Xcode 6.3.

NSArray *array = @[@"Ari",@"Gow",@"Pra"];
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];

for (int j = 0; j < [array count]; j++) {
    UIAlertAction *defaultAction = [UIAlertAction actionWithTitle:[array objectAtIndex:j] style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
    }];
    [alertController addAction:defaultAction];
}

UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
}];
[alertController addAction:cancelAction];
[alertController setModalPresentationStyle:UIModalPresentationPopover];
UIPopoverPresentationController *popPresenter = [alertController popoverPresentationController];
popPresenter.sourceView = self.view;
popPresenter.sourceRect = [self.view frame];
dispatch_async(dispatch_get_main_queue(), ^ {
    [self presentViewController:alertController animated:YES completion:nil];
});

enter image description here


Solution

  • This is only apparent height of the UIAlertController. It is so because you are running the project in the iPhone 6 simulator but your old project does not support UI for iPhone 6 screen size. In XCode 6.3 the iPhone 6 screen-size is supported, hence the smaller (apparent) height.