Tag: ios8 today widget

iOS8今天扩展使用只有自动布局的高度给破坏的约束

Apple文档build议使用自动布局设置Today Extensions的高度。 如果一个小部件有额外的内容要显示,你可以依靠自动布局约束来适当调整小部件的高度。 如果您不使用自动布局,则可以使用UIViewController属性preferredContentSize指定窗口小部件的新高度。 但是,我看到的每个示例和教程都使用preferredContentSize 。 我所有尝试通过自动布局来设置高度的方法都会导致警告。 通过Autolayout设置高度 我开始使用新的xcode模板,以及新的今天的扩展模板。 我添加到TodayViewController.m是: – (UIEdgeInsets)widgetMarginInsetsForProposedMarginInsets:(UIEdgeInsets)defaultMarginInsets { return UIEdgeInsetsMake(0, 0, 0, 0); } 注意:如果我只使用默认页边距,我仍然遇到这个问题。 我限制了标签高度,将容器中的标签居中,并将容器高度限制为与标签高度相同: 这应该导致一个标签,在指定的高度填充容器,没有约束冲突。 相反,我得到一个约束冲突: 2014-09-28 10:27:39.254 TodayExtension[61090:2672196] Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and […]

今天iPad的扩展高度远远大于指定的高度

My Today扩展需要基于窗口小部件显示的内容具有dynamic高度。 我可以通过在最底部的元素上添加一个约束来实现:底部布局指南的顶部小于或等于底部最底部元素的底部,常数为0,优先级为999,乘数为1。 这与iPhone上的预期完全相同 – 小部件高度适合所有内容,并在显示下一个小部件之前应用默认的底部边距。 但在iPad上,它似乎将我的部件的高度设置为等于最大高度通知中心将允许一个部件 – 我的部件下面有很多空间,它几乎全屏。 我怎样才能删除额外的空间? 我确切地知道问题是什么,但不知道如何解决它 – 请参阅“问题”部分。 首先让我解释一下设置: 设置: 我把这个扩展的视图放在一个故事板上,没有任何事情是以编程的方式完成的。 视图由5个垂直堆叠的元素组成,其他一些水平排列。 这些是从上到下的垂直线的自动布局约束 – 没有说优先级是1000,乘数1: UILabel: height = 35, top space to top layout guide with constant of 10 UIButton: equal height and width to a different button (whose aspect ratio is 1:1, there is no fixed width/height), top space […]

今日扩展无法inheritanceCoreMedia权限

我正在试图在Swift中添加一个Today Extension来到我的Objective-C应用程序。 我一直在我的debugging器日志中收到此消息: Failed to inherit CoreMedia permissions from 3005: (null) 。 数字 3005每次都不一样。 我正在从窗口小部件中读取NSUserDefaults,但是我正在读取/写入应用程序本身。 我的TodayViewController中唯一的代码是这样的: override func viewDidLoad() { super.viewDidLoad() let formatter = NSNumberFormatter() formatter.numberStyle = .CurrencyStyle totalLabel.text = formatter.stringFromNumber(0) coinsLabel.text = formatter.stringFromNumber(0) formatter.maximumFractionDigits = 0 billsLabel.text = formatter.stringFromNumber(0) } func widgetMarginInsetsForProposedMarginInsets(defaultMarginInsets: UIEdgeInsets) -> UIEdgeInsets { return UIEdgeInsetsMake(8.0, 16.0, 8.0, 16.0) } func widgetPerformUpdateWithCompletionHandler(completionHandler: […]