IOS:单击AlertView上的按钮时显示视图
我试图在RedBoxViewController上显示一个迷你箱。当用户按下AlertView上的Ok(确定)按钮时,ViewController上应显示迷你框 RedBoxView是根视图,当用户收到alertView时,它会出现在屏幕上。 我正试图找到展示红盒子的方法。已经好几天了,我想不出别的办法了 我知道我不应该按下已经在屏幕上的viewcontroller。我认为这就是问题所在。因为当我在另一个故事板上的另一个Viewcontroller上时,视图被推送到RedBoxViewController,我可以看到迷你箱。但是,当我在RedBoxViewController上时,我希望看到它 收到alertView后,在屏幕上显示迷你箱的方式有哪些 我在App Delegate中有以下代码:IOS:单击AlertView上的按钮时显示视图,ios,Ios,我试图在RedBoxViewController上显示一个迷你箱。当用户按下AlertView上的Ok(确定)按钮时,ViewController上应显示迷你框 RedBoxView是根视图,当用户收到alertView时,它会出现在屏幕上。 我正试图找到展示红盒子的方法。已经好几天了,我想不出别的办法了 我知道我不应该按下已经在屏幕上的viewcontroller。我认为这就是问题所在。因为当我在另一个故事板上的另一个Viewcontroller上时,视图被推送到RedBoxViewContr
- (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];
}
}
你想打开视图或导航到另一个视图控制器我已经在视图控制器上,我想在警报视图上按“确定”按钮时显示隐藏视图。将代码添加到你的RedBoxViewControllerI添加的-voidalertView:UIAlertView*警报视图单击按钮索引:NSIntegerbuttonIndex{}在RedBoxViewController中,但它不工作:/我找到了!!