2015-07-06 3 views
0

У меня есть встроенные уведомления Apple push-уведомления в моем приложении. Когда выдается уведомление, я получаю представление предупреждения и при нажатии на просмотр, я перехожу к контроллеру детали. Но после нажатия кнопки просмотра он ничего не делает и замораживает приложение. Вот мой код, чтобы открыть информацию в режиме просмотра предупреждений:Объявление делегата приложения для Apple Push Notification не содержит viewcontroller

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 
DetailsViewController *list = [[DetailsViewController alloc]initWithNibName:@"Details" bundle:nil]; 

RearTableViewController *rearView = [[RearTableViewController alloc] init]; 
UINavigationController *frontNavigationController = [[UINavigationController alloc] initWithRootViewController:list]; 
UINavigationController *rearNavigationController = [[UINavigationController alloc] initWithRootViewController:rearView]; 

SWRevealViewController *mainRevealController = [[SWRevealViewController alloc] 
               initWithRearViewController:rearNavigationController frontViewController:frontNavigationController]; 

mainRevealController.delegate = self; 
[self.window.rootViewController presentViewController:mainRevealController animated:YES completion:nil]; 
[self.window makeKeyAndVisible]; 

Заранее благодарим за внимание!

+0

Где код, который вы отправили? – rmaddy

+0

Вы не установили 'rootViewController' только что созданного' self.window'. –

+0

Перед представлением mainRevealController убедитесь, что у вас есть rootViewController. –

ответ

1
//Don't realloc self.window. 
//self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 
DetailsViewController *list = [[DetailsViewController alloc]initWithNibName:@"Details" bundle:nil]; 


//Alloc this VC with nib name like initWithNibNamed:bundle: 
RearTableViewController *rearView = [[RearTableViewController alloc]initWithNibName:@"RearTableViewController" bundle:nil]; 
    UINavigationController *frontNavigationController = [[UINavigationController alloc] initWithRootViewController:list]; 
UINavigationController *rearNavigationController = [[UINavigationController alloc] initWithRootViewController:rearView]; 

SWRevealViewController *mainRevealController = [[SWRevealViewController alloc] 
               initWithRearViewController:rearNavigationController frontViewController:frontNavigationController]; 

mainRevealController.delegate = self; 
if(self.window.rootViewController){ 
     [self.window.rootViewController presentViewController:mainRevealController animated:YES completion:nil]; 
} 
else{ 
    self.window.rootViewController = mainRevealController; 
} 
    [self.window makeKeyAndVisible]; 

Надеюсь, что это сработает.

+0

спасибо. Это сработало! – sam24

0

Удалить следующий код.

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 

Не нужно выделять окно еще раз. Если вы это сделаете, вам нужно снова установить rootViewController.

Смежные вопросы