ios – dismissViewControllerAnimated无效

前端之家收集整理的这篇文章主要介绍了ios – dismissViewControllerAnimated无效前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在 IOS6上使用Storyboard.我试图回到以前的viewcontroller,但它无法正常工作.

我在这里定制了我的后门按钮.

  1. UIButton *btnBack = [UIButton buttonWithType:UIButtonTypeCustom];
  2. btnBack.frame = CGRectMake(0,45,35);
  3. [btnBack setTitle:@"Back" forState:UIControlStateNormal];
  4. [btnBack.titleLabel setFont: [UIFont fontWithName:@"Courier" size:15]];
  5. btnBack.layer.cornerRadius=5.0;
  6. btnBack.layer.borderWidth=2.0;
  7. [btnBack setBackgroundColor:[UIColor colorFbBlue]];
  8. btnBack.layer.borderColor=[UIColor colorFbBlue].CGColor;
  9. [btnBack setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  10. [btnBack addTarget:self action:@selector(Click_On_Btn_Back) forControlEvents:UIControlEventTouchUpInside];
  11. UIBarButtonItem *backBarButton = [[UIBarButtonItem alloc] initWithCustomView:btnBack];
  12.  
  13. -(void)Click_On_Btn_Back{
  14. [self dismissViewControllerAnimated:YES completion:nil];
  15.  
  16. }

这就是我从前一个视图控制器推送segue的方式.

  1. if([segue.identifier isEqualToString:@"segueFbShare"]){
  2. FbShareViewController *fbVC=[segue destinationViewController];
  3. fbVC.imageUrl=self.product.ImageUrl;
  4.  
  5. }

解决方法

使用UINavigationController时转到上一个UIViewController:
  1. [self.navigationController popViewControllerAnimated:YES];

将这行代码放在Click_On_Btn_Back方法

猜你在找的iOS相关文章