【发布时间】:2013-09-05 04:28:18
【问题描述】:
我正在创建一个新闻应用,其中主要有 2 个 UIViewcontroller:
- 重大新闻
- 主页
突发新闻显示带有平铺图像和一些描述的最新消息。 在首页中,我可以选择我想要的新闻类型,例如体育、政治等。因此每次它都会在首页中显示该类型的新闻。
我的问题是
当我打开应用程序时,我可以看到突发新闻,然后我点击了一条新闻,它会在新的UIViewController 中打开,其中包含与该新闻相关的所有图片和说明。
如果我从该描述页面单击下一个标签栏按钮,它将打开主页UIViewController 并崩溃。有时我可以看到主页UIViewController,当我打开新闻时,它就崩溃了。
如果我点击后退按钮,我会到达突发新闻页面,然后它不会崩溃。
但此问题仅在 iOS 6.0+ 版本中出现。我尝试在 iOS 5.1 设备上运行相同的应用程序,它运行良好。
崩溃日志
-[DescriptionPageViewController respondsToSelector:]: message sent to deallocated instance 0x1f59a370`
更新 刚才我尝试再次在 ipad 6.1 模拟器中使用断点运行相同的用例,但它在那里工作正常并且在没有断点设备的情况下崩溃***为什么????
Appdelegate 代码
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
if (![[NSUserDefaults standardUserDefaults] boolForKey:@"everLaunched"]==YES) {
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"everLaunched"];
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"firstLaunch"];
[[NSUserDefaults standardUserDefaults] synchronize];
[self loadingControllers];
}
return YES;
}
-(void)loadingControllers{
BreakingNewsViewController *breaking = [[BreakingNewsViewController alloc] initWithNibName:@"BreakingNewsViewController" bundle:nil];
UIViewController *home = [[homepage alloc] initWithNibName:@"homepage" bundle:nil];
UINavigationController*viewController1 = [[UINavigationController alloc] initWithRootViewController:breaking];
UINavigationController *viewController2 = [[UINavigationController alloc] initWithRootViewController:home];
viewController1.navigationBarHidden = YES;
viewController2.navigationBarHidden = YES;
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.tabBar.backgroundImage = [UIImage imageNamed:@"Tabbar_bg.png"];
// self.tabBarController.tabBar.tintColor=[UIColor darkGrayColor];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1,
viewController2
,nil];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
[self.tabBarController setDelegate:self];
}
【问题讨论】:
-
Crashing...crashing...crashing.. 在问题中添加崩溃日志!!
-
@Anil 在你发布之前我已经添加了日志 ok
-
当我开始评论时它不存在..:) 你在使用 ARC 吗?
-
请停止使用这么多大写(大喊大叫)和这么多粗体文字。这让你的问题读起来很烦人。
-
DescriptionPageViewController 对象在哪里分配和初始化?
标签: ios objective-c uiviewcontroller crash uitabbarcontroller