Ios 是否将消息发送到解除分配的实例0x9553970?关于设置UITABBARC控制器的委托

Ios 是否将消息发送到解除分配的实例0x9553970?关于设置UITABBARC控制器的委托,ios,objective-c,delegates,uitabbarcontroller,Ios,Objective C,Delegates,Uitabbarcontroller,在我的iOS应用程序中,我使用my MainViewController.m中的以下方法将rootview控制器中的一个选项卡栏控制器替换为另一个选项卡控制器 //Set Tab Bar View as per the Analyst User -(void)setTabrViewforAnalyst{ tabBarController_main = [[UITabBarController alloc] init]; // Create initialized instance

在我的iOS应用程序中,我使用my MainViewController.m中的以下方法将rootview控制器中的一个选项卡栏控制器替换为另一个选项卡控制器

//Set Tab Bar View as per the Analyst User
-(void)setTabrViewforAnalyst{
    tabBarController_main = [[UITabBarController alloc] init];
    // Create initialized instance of NSMutableArray to hold our UINavigationControllers
    NSMutableArray *tabs = [[NSMutableArray alloc] init];

    tabBarController_main.delegate=self;

    // Create first UIViewController

    PlannedEventViewController *plannedView=[[PlannedEventViewController alloc]initWithNibName:@"PlannedEventViewController" bundle:nil];
    UINavigationController *plannedNavigationView=[[UINavigationController alloc]initWithRootViewController:plannedView];

    // Initialize the UINavigationController

    [tabs addObject:plannedNavigationView];

    MyVideoViewController *videoView=[[MyVideoViewController alloc]initWithNibName:@"MyVideoViewController" bundle:nil];
    UINavigationController *videoNavigationView=[[UINavigationController alloc]initWithRootViewController:videoView];
    // Add UINavigationController to you tabs
    [tabs addObject:videoNavigationView];


    MyTeamViewController *myTeamview=[[MyTeamViewController alloc]initWithNibName:@"MyTeamViewController" bundle:nil];
    UINavigationController *myTeamNavigationView=[[UINavigationController alloc]initWithRootViewController:myTeamview];
     // Add UINavigationController to you tabs
    [tabs addObject:myTeamNavigationView];


    // Create second UIViewController
    SettingViewController *settingView=[[SettingViewController alloc]initWithNibName:@"SettingViewController" bundle:nil];
    UINavigationController *settingNavigationView=[[UINavigationController alloc]initWithRootViewController:settingView];

       settingView.isLoggedIn=YES;
    // Add UINavigationController to you tabs
    [tabs addObject:settingNavigationView];
    // Add the tabs to the UITabBarController



    // Create second UIViewController

    // Add the tabs to the UITabBarController
    [tabBarController_main setViewControllers:tabs];



    tabBarController_main.tabBar.backgroundImage = [UIImage imageNamed:@"tab_back.png"];

    UIImage *selectedImage1 = [UIImage imageNamed:@"my_team.png"];
    UIImage *unselectedImage1 = [UIImage imageNamed:@"my_team.png"];

    UIImage *selectedImage0 = [UIImage imageNamed:@"events.png"];
    UIImage *unselectedImage0 = [UIImage imageNamed:@"events.png"];

    UIImage *selectedImage2 = [UIImage imageNamed:@"video"];
    UIImage *unselectedImage2 = [UIImage imageNamed:@"video.png"];

    UIImage *selectedImage3 = [UIImage imageNamed:@"settings.png"];
    UIImage *unselectedImage3 = [UIImage imageNamed:@"settings.png"];


    UITabBar *tabBar = tabBarController_main.tabBar;
    UITabBarItem *item0 = [tabBar.items objectAtIndex:0];
    UITabBarItem *item1 = [tabBar.items objectAtIndex:1];
    UITabBarItem *item2 = [tabBar.items objectAtIndex:2];
    UITabBarItem *item3 = [tabBar.items objectAtIndex:3];


    [item0 setFinishedSelectedImage:selectedImage0 withFinishedUnselectedImage:unselectedImage0];
    [item1 setFinishedSelectedImage:selectedImage2 withFinishedUnselectedImage:unselectedImage2];
    [item2 setFinishedSelectedImage:selectedImage1 withFinishedUnselectedImage:unselectedImage1];
     [item3 setFinishedSelectedImage:selectedImage3 withFinishedUnselectedImage:unselectedImage3];

    item0.title = @"a";
    item1.title = @"b";
    item2.title=@"c";
    item3.title = @"d";

    //Check OS version
    NSString *strOsVersion = [[UIDevice currentDevice] systemVersion];
    float osVersionFloat = [strOsVersion floatValue];

    if (osVersionFloat >= 7.0)
        tabBar.translucent = false;

    tabBar.tintColor = [UIColor colorWithRed:234.0/256.0 green:234.0/256.0 blue:234.0/256.0 alpha:1.0];
     [[UITabBar appearance] setSelectionIndicatorImage:[UIImage imageNamed:@"tab_selected_blue2.png"]];

    tabBarController_main.selectedIndex=3;

    AppDelegate *app = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    app.window.rootViewController = tabBarController_main;


}

但是,当我在MainViewController.m中将UITabbarController delegate的委托设置为self时,我从这里创建选项卡栏,导致应用程序崩溃,出现错误[MainViewController respondsToSelector:]:消息发送到解除分配的实例0x9553970,有人能告诉我应该是什么问题吗?tabBarController_main是.h文件的我的属性

问题在于,要么您在计划之前释放了MainViewController,要么是其他东西意外释放了它。您可以在[-MainViewController dealloc]中设置断点,并在调试器中停止,然后检查堆栈以了解发生此情况的原因。

谁在控制MainViewController?我无法理解您的观点。。