preferredContentSize在ios 7中不起作用? [英] preferredContentSize not working in ios 7?

查看:175
本文介绍了preferredContentSize在ios 7中不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用类型为UIModalPresentationFormSheetmodalPresentationStyle来显示我的视图.我想要特定的视图大小,所以使用preferredContentSize可以在iOS 8中工作,并显示我想要的确切方式,但对于iOS 7它是整张纸.视图大小已更改.

I am using modalPresentationStyle of type UIModalPresentationFormSheet to show my view.I want specific size of the view so using preferredContentSize which working in iOS 8 and showing exact how I wanted but same breaks for iOS 7 it's come as full sheet.View size changed.

在我想要的地方,如下面的图片

Where as I wanted like below image

有什么主意吗?

推荐答案

请检查以下适用于iOS 8.x和iOS 7的条件代码

Please check below conditional code for iOS 8.x and iOS 7

if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")) 
{
    modalController.preferredContentSize = CGSizeMake(frameSize.x, frameSize.y); 
}
else 
{
    modalController.view.superview.frame = CGRectMake((screenWidth - frameSize.x)/2, (screenHeight - frameSize.y)/2, frameSize.x, frameSize.y);

}

希望这会对您有所帮助.

Hope this will help you.

这篇关于preferredContentSize在ios 7中不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆