m1entus / MZFormSheetPresentationController

MZFormSheetPresentationController provides an alternative to the native iOS UIModalPresentationFormSheet, adding support for iPhone and additional opportunities to setup UIPresentationController size and feel form sheet.
MIT License
973 stars 146 forks source link

Center not work #3

Closed SadhuRus closed 9 years ago

SadhuRus commented 9 years ago

I Love MZFormSheetPresentationController !!! =)

But I was not happy with the location of the Pop-up'a. It is located just below the Navigation Controller'a. All attempts to move it to the center of the screen does not lead to any success.

My code:

LikeChoiceNavigationController *choiceNavigationController = [STORYBOARD instantiateViewControllerWithIdentifier:@"LikeChoiceNavigationController"];

MZFormSheetPresentationController *formSheetController = [[MZFormSheetPresentationController alloc] initWithContentViewController:choiceNavigationController];

formSheetController.contentViewSize = CGSizeMake(280, 320);
formSheetController.shouldDismissOnBackgroundViewTap = YES;
formSheetController.shouldCenterVertically = YES;
formSheetController.contentViewControllerTransitionStyle = MZFormSheetTransitionStyleBounce;

[navigationController presentViewController:formSheetController animated:YES completion:nil];
m1entus commented 9 years ago

If you open example you will see that it is wokring, make sure that movementActionWhenKeyboardAppears you have set to MZFormSheetActionWhenKeyboardAppearsDoNothing

SadhuRus commented 9 years ago

I try it. But not work.

In the example, it is also no longer work if you delete the line: presentedViewController.textFieldBecomeFirstResponder = YES;

I want to use a pop-up window without TextField.

SadhuRus commented 9 years ago

I change you default code and now it work for me:

@autoreleasepool {
    MZFormSheetPresentationController *appearance = [self appearance];
    [appearance setContentViewSize:CGSizeMake(284.0, 284.0)];
    [appearance setPortraitTopInset:66.0];
    [appearance setLandscapeTopInset:6.0];
    [appearance setContentViewCornerRadius:5.0];
    [appearance setBackgroundColor:[UIColor colorWithWhite:0 alpha:0.5]];
    [appearance setShouldCenterVertically:YES];
    [appearance setBlurEffectStyle:UIBlurEffectStyleLight];
    [appearance setMovementActionWhenKeyboardAppears:MZFormSheetActionWhenKeyboardAppearsDoNothing];
}

P.S: I Added this line in +(void)load:

[appearance setShouldCenterVertically:YES];
lumucheng commented 9 years ago

hi, i'm also facing the issue where the shouldCenterVertically does not work unless the software keyboard is being triggered.

Any solutions without directly modifying the source files?

lumucheng commented 9 years ago

I just found a solution for this; You need to specify .shouldCenterVertically before setting the contentViewSize.

i.e instead of:

let formSheet = MZFormSheetPresentationController(contentViewController: viewController)
formSheet.contentViewSize = CGSizeMake(280.0, 280.0)
formSheet.contentViewControllerTransitionStyle = .StyleFade
formSheet.shouldDismissOnBackgroundViewTap = true
formSheet.shouldCenterVertically = true

do this

let formSheet = MZFormSheetPresentationController(contentViewController: viewController)
formSheet.shouldCenterVertically = true
formSheet.contentViewSize = CGSizeMake(280.0, 280.0)
formSheet.contentViewControllerTransitionStyle = .StyleFade
formSheet.shouldDismissOnBackgroundViewTap = true
klauslanza commented 9 years ago

Is it possible to set the controller position like the old version? I'd like it to be near the right edge of the screen (not useful on iphone but on ipad a lot!)

Thanks