我正在尝试在RedBoxViewController上显示一个miniBox。当用户按下AlertView上的Ok按钮时,miniBox应出现在ViewController上。
RedBoxView是rootView,当用户收到alertView时,它位于屏幕上。 我正试图找到显示redbox的方法。已经好几天了,我可以'想想任何其他方式。
我知道我不应该推送已经在屏幕上的viewcontroller。我认为这就是问题所在。因为当我在另一个故事板上的另一个Viewcontroller上时,视图被推送到RedBoxViewController,我能够看到miniBox。但是当我在RedBoxViewController上时,我想看到它。
收到alertView后,屏幕上显示minibox的方法有哪些?
我在App Delegate中有以下代码:
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
if ([[userInfo objectForKey:@"aps"] objectForKey:@"alert"]) {
NSString *message = [[userInfo objectForKey:@"aps"] objectForKey:@"alert"];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Package here"
message: message
delegate: self
cancelButtonTitle: @"OK"
otherButtonTitles: nil];
[alert show];
}
}
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 0) {
NSLog(@"The OK button was clicked for alertView");
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"RedStoryboard" bundle:nil];
RedBoxViewController *redBoxView = (RedBoxViewController *)[storyboard instantiateViewControllerWithIdentifier:@"redBoxView"];
redBoxView.miniBox.hidden = NO;
[(UINavigationController *)self.window.rootViewController pushViewController:redBoxView animated:NO];
}
}