0

Since appDelegate does not have a view, just window, its hard to figure out how to load a view from it. My problem has for long been that when didReceiveLocalNotification fires i cant load a new view with that event. I have been working around it til the point that i must do something about it. When i tries to addSubview, xcode gives me the error:

Receiver tupe 'UIWindow' for instance messages does not declare a method with selector 'addSubView'

for this: (at [self.window addSubView:view];)

screwLightBulbViewController *view = [screwLightBulbViewController newMyView];
[self.window addSubView:view];

I understand that the appDelegate file does'nt have a addSubview but i want to switch to a particular view when it fires.

I have tried many other ways, like calling a function in screwLightBulbViewController and make a view from that. My function in the viewController now looks like this:

+(id)newMyView
{
    UINib *nib = [UINib nibWithNibName:@"MyView" bundle:nil];
    NSArray *nibArray = [nib instantiateWithOwner:self options:nil];
    screwLightBulbViewController *me = [nibArray objectAtIndex: 0];
    return me;
}

any help in any way would be realy appreciated and thanks for you time. :)

4

1 回答 1

2

addSubview不是addSubView:。_ UIWindow是 的子类UIView

通常不建议将视图直接作为子视图添加到窗口,因此您应该尝试将视图作为子视图添加到顶部控制器视图。如果你有空的话,你应该看看视图编程指南视图控制器编程指南,它在未来会有用。

于 2012-01-29T11:59:21.660 回答