ios – dismissViewControllerAnimated无效

我在 IOS6上使用Storyboard.我试图回到以前的viewcontroller,但它无法正常工作.

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

UIButton *btnBack = [UIButton buttonWithType:UIButtonTypeCustom];
btnBack.frame = CGRectMake(0,45,35);
[btnBack setTitle:@"Back" forState:UIControlStatenormal];
[btnBack.titleLabel setFont: [UIFont fontWithName:@"Courier" size:15]];
btnBack.layer.cornerRadius=5.0;
btnBack.layer.borderWidth=2.0;
[btnBack setBackgroundColor:[UIColor colorFbBlue]];
btnBack.layer.borderColor=[UIColor colorFbBlue].CGColor;
[btnBack setTitleColor:[UIColor whiteColor] forState:UIControlStatenormal];
[btnBack addTarget:self action:@selector(Click_On_Btn_Back) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *backBarButton = [[UIBarButtonItem alloc] initWithCustomView:btnBack];

-(void)Click_On_Btn_Back{
[self dismissViewControllerAnimated:YES completion:nil];

 }

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

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

}

解决方法

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

将这行代码放在Click_On_Btn_Back方法

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...