简体   繁体   中英

How to adjust today extension width for iOS 9 iPad Notification in landscape mode?

So in iOS 9 for iPad the landscape mode splits the notification center into 2 unequal halves. Before, my today extension would fit perfectly in the notification center whether it was landscape or portait mode.

Does anyone know how to resize/scale my today extension to for the new iOS9 landscape notification center? Also is there any particular way to find out if the widget/today extension will be on the left hand side or right hand side of the notification center? (since they are different widths)

这是显示两个不同大小的一半的屏幕截图。

I have looked into, using autoResizing and autoResizeSubviews. But that doesnt seem to be working.

Thanks!

I had the same problem and I resolved it by obtaining my widget extension width with:

self.view.bounds.size.width

Attention, you have to access self.view in viewDidAppear because on viewDidLoad it may be incorrect, as reported here: Getting width of the Notification-Center inside Today-Extension

Actually, as I know, there is no API to know if your widget is on the left or on the right side of the notification center. But, for example, you can determine it by checking the ratio ( screensize / widget-size ), or you can calculate your layout in a relative manner, based on the width of your widget, as I do and I recommend.

Just for a numeric example, on the iPad mini 1 with iOS 9, the screen size in landscape is 1024*768, the widget width on the left side is 471 points and on the right side is 328 points.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM