【发布时间】:2012-03-12 17:23:17
【问题描述】:
- 在我的窗口基础应用程序中,当我单击警报视图按钮时,我需要从我的 appdelegate 导航到信息视图。
- 警报视图适用于 NSlog。
-
但我需要为此目的推送到另一个视图
[self.navigationController pushViewController:info Animation:YES];
但它不会推动。只是 nslog 只打印
- (void)applicationDidBecomeActive:(UIApplication *)application
{
//To count the number of launches
NSInteger i = [[NSUserDefaults standardUserDefaults] integerForKey:@"numOfCalls"];
[[NSUserDefaults standardUserDefaults] setInteger:i+1 forKey:@"numOfCalls"];
NSLog(@"the number of active calls are %d",i%3);
if(i%3==0 && i!=0)
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"you might prefer MedChart+" message:@"Get it now for more options" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok",nil];
[alert show];
[alert release];
}
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 0)
{
NSLog(@"canceled");
}
else if (buttonIndex == 1)
{
NSLog(@"Pushed to the information view ");
InformationViewCotroller *info = [[InformationViewCotroller alloc]initWithNibName:@"InformationViewCotroller" bundle:nil];
[self.navigationController pushViewController:info animated:YES];
}
}
(不要认为“i”值是我的逻辑的一部分)。 提前致谢
【问题讨论】:
-
您是否验证过 self.navigationController 是一个有效的对象?
-
是的,我已经在 appdelegate.h 中声明了
-
您是否在调试器或日志中打印了它的值?
标签: iphone objective-c xcode uinavigationcontroller pushviewcontroller