获取iOS今天扩展的宽度 [英] Get width of iOS today extension
问题描述
我想获取我的小部件/今天扩展名的宽度值.
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屋!