iOS 8今日扩展中的适合宽度 [英] Fit width in iOS 8 Today Extensions

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

问题描述

当我制作任何iOS 8 Today Extension时,左边有一个大约48px的空白区域,即使在Interface Builder中我在x = 0左侧放置了一个标签。

When I make any iOS 8 Today Extension, there is an empty space on the left of approximately 48px, even if in Interface Builder I place a label on the left side at x=0.


我已经看到一些应用程序使用全宽小部件。

I have seen that some apps, however, use a full-width widget.

我如何实现类似的目标?

How can I achieve something similar?

谢谢!

更新:已解决

我在这里放了示例代码,因为我猜这对某人有用。正如@ matteo-lallone所建议的那样,正确的方法是:

I put here the sample code because I guess it will be useful to someone. As suggested by @matteo-lallone, the correct way to do this is:

-(UIEdgeInsets)widgetMarginInsetsForProposedMarginInsets:(UIEdgeInsets)defaultMa‌​rginInsets{
return UIEdgeInsetsZero;
}


推荐答案

直接从文档:


使用Xcode Today模板创建的今日小部件包括Auto
标准边距插入的布局约束。要获得计算的插入值
,请实现
widgetMarginInsetsForProposedMarginInsets:方法。

A Today widget created using the Xcode Today template includes Auto Layout constraints for standard margin insets. To get the inset values for your calculations, implement the widgetMarginInsetsForProposedMarginInsets: method.

来源: App Extension Programming Guide - Today

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

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