-2

通常在viewController被推送之后,我想做一些事情。例如,在添加电话功能中,我会打开编辑业务并将焦点设置为电话字段。

如果在 viewController 被按下后用户太快按下返回按钮应用程序崩溃。

这样做的标准方法是什么?

这是代码:

+(BGBusinessEditViewController *) pushNewEditViewControllerWithBizandReturnValue: (Business *)biz withNavController :(UINavigationController *) nav andSelectPhone:(BOOL) selectPhoneAfterward
{
    BGBusinessEditViewController * editBusiness = [[BGBusinessEditViewController alloc]init];
    //[editBusiness view];//load the stuff first
    [nav vPushViewController:editBusiness animated:YES andPerformBlock:^{
        if (biz) {
            editBusiness.biz=biz; //viewDidload must be called first before setting bizs
        }
        if (selectPhoneAfterward)
        {
            [editBusiness selectPhone];
        }
    }];

    return editBusiness;
}

-(void) selectPhone
{
    NSIndexPath * ipth =[NSIndexPath indexPathForItem:BGBusinessEditTextPhoneNumber inSection:0];
    [self.tableView selectRowAtIndexPath: ipth animated:NO scrollPosition:UITableViewScrollPositionTop];
    [self tableView:self.tableView didSelectRowAtIndexPath:ipth];
}

基本上我在导航视图控制器中创建了一个类别,只有当导航控制器已经到达时才会运行代码- (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated;

4

1 回答 1

1

好吧,隐藏后退按钮直到viewDidAppear,然后取消隐藏它。

于 2013-05-17T09:25:03.420 回答