iOS   发布时间:2022-03-30  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了objective-c – 具有ModalPresentationStyle的Popover并不以iOS 7 iPad为中心大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个iOS 7的问题,似乎是一个错误,或者我只是不做正确的事情。@L_996_0@modalViewController,在iPad上显示为ModalPresentationStyle。它不是标准尺寸,定制尺寸。
这是代码

@H_404_8@myViewController *myVC = [[myViewController alloc] init]; UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:myVC]; [nav setModalPresentationStyle:UIModalPresentationFormSheet]; [nav setModalTransitionStyle: UIModalTransitionStyleFlipHorizontal]; [self presentViewController:nav animated:YES completion:nil]; nav.view.superview.bounds = CGRectMake(0,320,465);

在iOS 6中都可以正常工作,但在iOS 7中它并没有集中。
但是如果我将ModalTransitionStyle设置为UIModalTransitionStyleCrossDissolve它可以正常工作。但只能在这种模式下。
也许有人绊倒了这个,知道如何解决它?我不是溶解效应的大粉丝。
谢谢。

解决方法

我有一种方法,其中旧的自定义模式演示样式fromsheet适用于iOS< = 7,尽管您可以设置自定义的高度和宽度。 请记住,此方法将来可能无法在任何较新版本中运行

- (void) hackmodalSheetSize:(CGSizE) aSize ofVC:(UIViewController *) aController;
{

    void (^formSheetBlock) (void) = ^{
        int preferredWidth = aSize.width;
        int preferredHeight = aSize.height;

        CGRect frame = CGRectMake((int) 1024/2 - preferredWidth/2,(int) 768/2 - preferredHeight/2,preferredWidth,preferredHeight);
        aController.view.superview.frame = frame;
        if([aController respondsToSELEctor:@SELEctor(edgesForExtendedLayout)]) { //ios7
            aController.view.superview.BACkgroundColor = [UIColor clearColor];
        } else { // < ios7
            UIImageView *BACkgroundView = [aController.view.superview.subviews objectATindex:0];
            [BACkgroundView removeFromSuperview];
        }
    };

    //on ios < 7 the animation would be not as smooth as on the older versions so do it immediately
    if(![self respondsToSELEctor:@SELEctor(edgesForExtendedLayout)]) {
        formSheetBlock();
        return;
    }

    double delayInSeconds = .05;
    dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_Now,delayInSeconds * NSEC_PER_SEC);

    dispatch_after(popTime,dispatch_get_main_queue(),^(void){
        formSheetBlock();
    });
}

大佬总结

以上是大佬教程为你收集整理的objective-c – 具有ModalPresentationStyle的Popover并不以iOS 7 iPad为中心全部内容,希望文章能够帮你解决objective-c – 具有ModalPresentationStyle的Popover并不以iOS 7 iPad为中心所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。