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

本文是小编为大家收集整理的关于preferredContentSize在ios7中不起作用?的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

我使用UIModalPresentationFormSheet的modalPresentationStyle来显示我的视图.我想要视图的特定大小,因此使用preferredContentSize在iOS 8中工作的preferredContentSize,并显示了我想要的方式,但对于iOS 7它会随着完整的表格而变化.尺寸更改.

在此处输入图像说明

我想要的地方如下图

在此处输入图像说明

有什么想法吗?

推荐答案

请检查以下iOS 8.x和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);

}

希望这对您有帮助.

本文地址:https://www.itbaoku.cn/post/2091186.html

问题描述

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.

enter image description here

Where as I wanted like below image

enter image description here

Any idea?

推荐答案

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.