单击导航后退按钮,然后导航栏重叠相同视图

时间:2016-02-01 10:19:13

标签: ios objective-c

我有3个视图控制器A B和C.从B到C我可以将纵向模式导航到横向模式。现在好了。当我从C导航到B(横向到纵向模式)视图控制器时。然后现在又好了。但是在C视图控制器中我有一个自定义后退按钮。当我点击该按钮时,它将从C导航到B视图控制器。在B视图控制器页面中,我点击它重叠的导航后退按钮(不导航到A视图控制器)。两次后,它将导航到A视图控制器

1 个答案:

答案 0 :(得分:0)

您可以使用自己的自定义视图作为导航栏。检查一次:

self.navigationController.navigationBarHidden = YES;

UIView *newNavBar = [[UIView alloc] init];
newNavBar.backgroundColor = [UIColor colorWithRed:255.0/255.0 green:150.0/255.0 blue:0.0/255.0 alpha:1.0];

UIImageView *backgroundImgView = [[UIImageView alloc]init];
backgroundImgView.image = [UIImage imageNamed:@"abc_image"];
[newNavBar addSubview:backgroundImgView];

UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
backBtn.frame=CGRectMake(5,15, 50, 50);//set frames according to your req
[backBtn setImage:[UIImage imageNamed:@"xyz_icon"] forState:UIControlStateNormal];
[backBtn addTarget:self action:@selector(backBtnAction) //your method forControlEvents:UIControlEventTouchUpInside];
[newNavBar addSubview:backBtn];
[self.view addSubview:newNavBar];

对于推送/弹出等,这对我来说很好。

希望这有帮助。

相关问题