在iOS 9中不鼓励在分离的视图控制器上显示视图控制器?

时间:2016-04-20 07:23:11

标签: ios objective-c uitableview uiviewcontroller

在我的应用程序中,当我从tableview页脚部分移动到另一个视图控制器时,它移动正常但移动后应用程序将崩溃。之后我收到了这个错误。

enter image description here

这是我的代码:

-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    if(tableView == educateTbl) //here you can make a decision
    {
        float footerWidth = 150.0f;
        float padding = 10.0f;
        UIView *footerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, footerWidth, 50.0)];
        footerView.autoresizingMask = UIViewAutoresizingFlexibleWidth;

        UIButton *addEdu = [[UIButton alloc]initWithFrame:CGRectMake(padding, 0, footerWidth - 2.0f * padding, 44.0f)];
        addEdu.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
        addEdu.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;

        addEdu.backgroundColor = [UIColor colorWithRed:23/255.0 green:186/255.0 blue:239/255.0 alpha:1.0];
        [addEdu setTitle:@"Add Education" forState:UIControlStateNormal];
        [addEdu addTarget:self action:@selector(addEducation:) forControlEvents:UIControlEventTouchUpInside];
        [addEdu setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];//set the color this is may be different for iOS 7
        addEdu.frame=CGRectMake(0, 0, 200, 30); //set some large width to ur title
        [footerView addSubview:addEdu];
        return footerView;
    }
    return nil;
}

- (void)addEducation:(id)sender
{
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    AddEducationViewController *ivc = [storyboard instantiateViewControllerWithIdentifier:@"AddEducationVC"];
    [self presentViewController:ivc animated:YES completion:nil];
}

1 个答案:

答案 0 :(得分:0)

[self presentViewController:ivc animated:YES completion:nil];

尝试改变:

[self.view.window.rootViewController presentViewController:deleAlert animated:YES completion:nil];