Reputation: 118
i have a xib file associated with UIViewController (someViewController.m). in my application there is a navigation controller having 6 view controllers. now i want to implement local notifications and on tapping notification, i want to show someViewController on any view that was shown when application enters inactive or background state by pressing home button.how can i do this optimally. i also add observers applicationwillenterforegorundnotification in every class
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(comingfromNotification) name:UIApplicationWillEnterForegroundNotification object:nil];
-(void)comingfromNotification:(NSNotification *) notification{
RNASharedialogViewController *rsd=[[RNASharedialogViewController alloc]init];
rsd.modalPresentationStyle=UIModalPresentationFormSheet;
rsd.modalTransitionStyle=UIModalTransitionStyleCrossDissolve;
[self presentViewController:rsd animated:YES completion:nil];
rsd.view.frame=CGRectMake(15.0, 10.0, 292.0, 454.0);
}
is this a proper way ?
Upvotes: 1
Views: 384
Reputation: 846
The workaround you have implemented is ok I think. I did these type of works like yours. But one thing, I must mention that if your application is navigation controlled or tab bar controlled you should present the view based on the root controller. For example:
[self.navigationController presentViewController:rsd animated:YES completion:nil];
Upvotes: 1