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

时间:2013-09-05 04:28:19

标签: ios objective-c uiviewcontroller crash uitabbarcontroller

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

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

    我的问题是

    当我打开应用程序时,我可以看到突发新闻,并点击了一个新闻项目,因此它将在新UIViewController中打开,其中包含与该新闻相关的所有图像和说明。

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

    如果我点击后退按钮,那么我将到达突发新闻页面,然后它不会崩溃。

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

    崩溃日志

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

    enter image description here enter image description here

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

1 个答案:

答案 0 :(得分:5)

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

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

 // In BreakingNewsViewController.h

@property (strong, nonatomic) DescriptionPageViewController *descriptionPageViewController;

 // In BreakingNewsViewController.m

self.descriptionPageViewController = [[DescriptionPageViewController alloc]initWithNibName:@"DescriptionPageViewController "];
相关问题