IOS dismissViewControllerAnimated VS popViewControllerAnimated

来源:互联网 发布:php 短信验证码生成 编辑:程序博客网 时间:2024/06/05 18:13
设置 segue identifier 选择要跳转的连线命名  
779459.png 
程序中使用方法如下:

#pragma mark - Navigation 根据场景判断


// In a storyboard-based application, you will often want to do a little preparation before navigation

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

    

    NSLog(@"xx%@" ,[[segue identifier ] description] );

    if ([[segue identifierisEqualToString:@"sregister"]) {

     

    }

    // Get the new view controller using [segue destinationViewController].

    // Pass the selected object to the new view controller.

}


通过连接Push方法。
890248.png 
然后用  dismissViewControllerAnimated:YES 怎么也不生效。经过后面的努力发现要用  
 有 navigation 用需要   popViewControllerAnimated
  [ self . navigationController popViewControllerAnimated : YES ]; (自学习再怎么也得要走走弯路) 
// Dismisses the view controller that was presented modally by the view controller. 只限于窗口 

//            [self dismissViewControllerAnimated:YES completion:^{

//                NSLog(@"back");//这里打个断点,点击按钮模态视图移除后会回到这里

//            }];



以上是前人们的问题。

以上是前人们的问题。

443505.png


dismissViewController is used when you do not have a navigationcontroller. Most probably you are using a navigation controller, then use self.navigationController popViewController instead.

Also take note of lemax his remark: use NULL, not nill for the completionhandler


//跳转到指定的Segue

 [self performSegueWithIdentifier:@"userLogin" sender:nil];


0 0
原创粉丝点击