获取iOS今天扩展的宽度 [英] Get width of iOS today extension

查看:47
本文介绍了获取iOS今天扩展的宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获取我的小部件/今天扩展名的宽度值.

I want to get the width value of my widget / today extension.

我不能使用 self.view.frame.size.width ,因为它会返回整个屏幕宽度,而不是实际的小部件宽度(在iPad上,扩展名的宽度不等于屏幕宽度).

I can't use self.view.frame.size.width because it returns the whole screen width and not the actual widget width (on the iPad the width of the extension is not equal to the screen width).

如何获取小部件的实际宽度?

What can I do to get the actual width of the widget?

推荐答案

.........不要在 viewDidLoad 中阅读self.view.frame.

.............. Don't read self.view.frame in viewDidLoad.

frame =(0 0; 768 1024);//在viewDidLoad中

frame = (0 0; 768 1024); // in viewDidLoad

您应该在 viewDidAppear

viewDidAppear 之后,self.view.frame是内容的正确值.

after viewDidAppear, self.view.frame is right value for content.

frame =(0 0; 545 75.5);//在viewDidAppear中

frame = (0 0; 545 75.5); // in viewDidAppear

这篇关于获取iOS今天扩展的宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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