当我在tabbar iOS 6.0中打开新标签时,我的应用程序崩溃了?

shw*_*a p 2 crash objective-c uitabbarcontroller uiviewcontroller ios

我正在创建一个新闻应用,我主要有2个UIView控制器:

  1. 爆炸新闻
  2. 主页

突发新闻显示了瓷砖图像和一些描述的最新消息.在主页我可以选择我想要的体育,政治等新闻.所以每次它都会在主页内显示那种类型的新闻.

我的问题是

当我打开应用程序时,我可以看到突发新闻,并且我点击了一个新闻项目,因此它将以新的方式打开,UIViewController包含与该新闻相关的所有图像和描述.

如果我单击该描述页面中的下一个标签栏按钮,它将打开主页UIViewController并崩溃.有时我可以看到Home UIViewController,当我打开新闻时它会崩溃.

如果我点击后退按钮然后我将到达突发新闻页面然后它没有崩溃.

但是这个问题只出现在iOS 6.0+版本中.我尝试在iOS 5.1设备中运行相同的应用程序它正常工作.

崩溃日志

 -[DescriptionPageViewController respondsToSelector:]: message sent to deallocated instance 0x1f59a370`
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述 在此输入图像描述

更新 现在我试图再次使用断点IN 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];




}
Run Code Online (Sandbox Code Playgroud)

Pun*_*rma 5

你在DescriptionPageViewController内部分配/初始化BreakingNewsViewController.

请为DescriptionPageViewController具有强属性的对象创建属性.

 // In BreakingNewsViewController.h

@property (strong, nonatomic) DescriptionPageViewController *descriptionPageViewController;

 // In BreakingNewsViewController.m

self.descriptionPageViewController = [[DescriptionPageViewController alloc]initWithNibName:@"DescriptionPageViewController "];
Run Code Online (Sandbox Code Playgroud)