在tabbar iOS 6.0中打开新选项卡时,我的应用程序崩溃?

在tabbar iOS 6.0中打开新选项卡时,我的应用程序崩溃?,ios,objective-c,uiviewcontroller,crash,uitabbarcontroller,Ios,Objective C,Uiviewcontroller,Crash,Uitabbarcontroller,我正在创建一个新闻应用程序,其中我主要有2个UIViewController: 突发新闻 主页 “突发新闻”显示了最新的新闻,包括图片和一些描述。 在主页中,我可以选择我想要的新闻类型,如体育、政治等,所以每次它都会在主页中显示这类新闻 我的问题是 -[DescriptionPageViewController respondsToSelector:]: message sent to deallocated instance 0x1f59a370` 当我打开应用程序时,我可以看到突发新闻,

我正在创建一个新闻应用程序,其中我主要有2个UIViewController:

  • 突发新闻
  • 主页
  • “突发新闻”显示了最新的新闻,包括图片和一些描述。 在主页中,我可以选择我想要的新闻类型,如体育、政治等,所以每次它都会在主页中显示这类新闻

    我的问题是

     -[DescriptionPageViewController respondsToSelector:]: message sent to deallocated instance 0x1f59a370`
    
    当我打开应用程序时,我可以看到突发新闻,我点击了一条新闻,它将在新的
    UIViewController
    中打开,并显示与该新闻相关的所有图像和描述

    如果我在描述页面中单击下一个选项卡按钮,它将打开主页
    UIViewController
    ,然后崩溃。有时我可以看到主页
    UIViewController
    ,当我打开一条新闻时,它就崩溃了

    若我点击“后退”按钮,那个么我将进入“突发新闻”页面,然后它不会崩溃

    但这个问题只出现在iOS 6.0+版本中。我试着在iOS 5.1设备上运行同一个应用程序,它工作正常

    崩溃日志

     -[DescriptionPageViewController respondsToSelector:]: message sent to deallocated instance 0x1f59a370`
    

    更新 刚才我试着在iPad6.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];
    
    
    
    
    }
    

    您正在分配/初始化
    DescriptionPageViewController
    内部
    BreakingNewsViewController

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

     // In BreakingNewsViewController.h
    
    @property (strong, nonatomic) DescriptionPageViewController *descriptionPageViewController;
    
     // In BreakingNewsViewController.m
    
    self.descriptionPageViewController = [[DescriptionPageViewController alloc]initWithNibName:@"DescriptionPageViewController "];
    

    撞车…撞车…撞车。。将崩溃日志添加到问题中@Anil在你发布这篇文章之前,我已经添加了日志,当我开始评论它不在那里时:)你使用的是ARC吗?请停止使用如此多的大写(叫喊)和如此多的粗体文本。你的问题读起来很烦人。DescriptionPageViewController对象在哪里分配和初始化?@我现在正在运行你的修改puneet,你的更改应用程序在模拟器中工作..现在我在设备中尝试让我知道你的状态很多puneet正在工作…我可以知道为什么它会在原因之前崩溃吗?看看发生了什么也就是说,在ARC中,对象一旦被使用就会被释放,如果您没有使其强大的话。Strong相当于保留在ARC中。@好的。现在我还必须修复另一个崩溃。稍后再与您联系