今天Extension有一个标题,但没有iOS 8 [英] Today Extension has a title, but no body iOS 8

查看:88
本文介绍了今天Extension有一个标题,但没有iOS 8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试新的 TodayExtensions 按照WWDC视频为iOS和OS X创建扩展,第1部分中所述创建今日扩展的步骤/ em>的。我在提供的故事板中为ViewController添加了一个彩色的UIView。我在今天通知中心获得了一个标题,但是我没有看到我的彩色视图。它看起来像这样(我做了两个):

I am trying out the new TodayExtensions in iOS 8 and I followed the steps to create a Today Extension as described in the WWDC video Creating Extensions for iOS and OS X, Part 1. I added a colored UIView to the ViewController in the provided storyboard. I get a title in my "Today" Notification center, but I get no body with my colored view. It looks like this (I made two):

还有其他人得到这个吗?我在所有ViewControllers方法中设置了断点,没有任何东西被调用。我将Info.plist更改为直接转到我的VC类,而不是故事板,我什么都没得到。我可以在info.plist中更改今天扩展名的标题。

Is anyone else getting this? I set breakpoints in all of my ViewControllers methods and nothing gets called. I changed my Info.plist to just go directly to my VC class, instead of the storyboard and I get nothing still. I can change the title of the today extension in the info.plist.

推荐答案

首先,为了测试发生了什么,添加awakeFromNib到你的视图控制器并设置首选内容大小(Obj C中的所有代码):

First, to test that anything is happening, add awakeFromNib to your view controller and set preferred content size (all code in Obj C):

- (void)awakeFromNib {
    [super awakeFromNib];
    [self setPreferredContentSize:CGSizeMake(self.view.bounds.size.width, 50)];
}

如上所述,请注释掉默认的init方法并创建一个空的initWithCoder :绕过Beta 2中的一些错误:

As milesper said above, comment out the default init method and create an empty initWithCoder: to get around some bug in Beta 2:

-(id)initWithCoder:(NSCoder *)aDecoder
{
    self = [super initWithCoder:aDecoder];
    if (self) {
        // init
    }
    return self;
}

//- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
//    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
//    if (self) {
//        // Custom initialization
//    }
//    return self;
//}

现在清理然后再次运行。此时你应该看到它调整大小(确保添加带有文本的标签或要测试的东西)。

Now Clean and then run again. At this point you should see it resize (make sure you add a label with text or something to test).

确保使用普通的UIViewController类进行测试,而不是子类。一旦看到小部件大小响应,那么尝试一个子类。我今天花了一个小时才发现使用UICollectionViewController在Beta 2中不起作用(将提交RADAR)。

Make sure you test with a plain UIViewController class, not a subclass. Once you see your widget size respond, then try a subclass. I spent an hour today just to find out that using UICollectionViewController simply doesn't work in Beta 2 (will file a RADAR).

这篇关于今天Extension有一个标题,但没有iOS 8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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