开发者

Can't change the presentation and transition styles of modal views in Xcode (iPad)

开发者 https://www.devze.com 2023-04-12 17:41 出处:网络
I\'m currently having some trouble with modal views and popovers. It might be the same problem, but I\'m not sure.

I'm currently having some trouble with modal views and popovers. It might be the same problem, but I'm not sure.

The problem I'm having with moda开发者_开发知识库l views is that I can't change the animation or transition style. For instance, I write

self.modalPresentationStyle = UIModalPresentationPageSheet;
self.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:IpModal animated:YES];

but the modal view still appears full screen with its original transition style.

Also, the problem I'm having with popovers is pretty similar. Even though I call the dismissPopover:animated: method with "NO" as the parameter, the transition is still animated.

Thanks in advance.


modalPresentationStyle and modalTransitionStyle apply to the view controller that is to be presented modally, not the controller doing the presenting.

Your code should be

IpModal.modalPresentationStyle = UIModalPresentationPageSheet;
IpModal.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:IpModal animated:YES];


I did this in custom segue.

UIViewController* src = self.sourceViewController;
UIViewController* dst = self.destinationViewController;

src.modalPresentationStyle = UIModalTransitionStyleFlipHorizontal;
dst.modalPresentationStyle = UIModalTransitionStyleFlipHorizontal;
[src presentModalViewController:dst animated:YES];


#import yourViewController.m //already present
#import destinationVieController.m //to be added by programmer

//custom function to call destination controller

-(void)callDestinationViewController{

    destinationViewController *dest = [[destinationViewController alloc] initWithNibName:@"destinationViewController" bundle:nil];

    dest.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    [self presentModalViewController:dest animated:YES];

  }

//custom function can be called on event fire or action call

Hope This Helps !


Perhaps you could try using one of these two methods to present the popover controller, depending on where you want it to appear, rather than presentModalViewController:animated:.

– presentPopoverFromRect:inView:permittedArrowDirections:animated:
– presentPopoverFromBarButtonItem:permittedArrowDirections:animated:
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号