0

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

Gowtham
  • 117
  • 12
  • yes, have same ios 8.3 – Gowtham Sep 11 '15 at 07:20
  • And same device also? – tuledev Sep 11 '15 at 07:22
  • Did you change anything in setting of device, like font size ...? – tuledev Sep 11 '15 at 07:26
  • No, i didn't change anything – Gowtham Sep 11 '15 at 07:29
  • probably the base SDK is different, however you are talking about different Xcode versions only, but if you have not changed the base-SDK manually (not the target!) then the SDKs must be different, which could cause the issue you saw; but from another view, that actually does not cause any problem in your app's behaviour, so what would your problem be actually here? – holex Sep 11 '15 at 08:10

1 Answers1

1

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.

Nishant
  • 12,529
  • 9
  • 59
  • 94
  • But i'm using the same height (320x568) for both UI. – Gowtham Sep 11 '15 at 08:00
  • Using the same height doesn't mean that it will look the same in all devices. Obviously, the rendering of UI will be dependent on **AutoLayout/Autosizing** that you have used. Nevertheless, all this should not be a good concern. – Nishant Sep 11 '15 at 08:21
  • Sorry, If you are building using the old SDK, then you won't be able to support iPhone 6 screens. You will have to use Xcode 6.0 and above to make a build for smaller screen devices as well. – Nishant Sep 11 '15 at 10:04
  • currently i'm using the xcode 6.3 with SDK8.3 for both project. – Gowtham Sep 11 '15 at 10:19
  • works great :) Thanks accepted answer. please add this solution in answer – Gowtham Sep 11 '15 at 11:30