为什么总是导航到主页View-ios

时间:2013-06-06 10:21:21

标签: iphone uinavigationcontroller stack xib popviewcontroller

我的应用包含5 xib
当我导航到Home to 2nd View并返回Home时工作正常 但从第三视图和点击返回它的每次推送到主页视图,我试试这个

-(IBAction)doBack
{
[self.navigationController popViewControllerAnimated:YES];
}
<。>在.xib文件中添加了UIView,并在该视图中添加了一个UIButton。

  • 还尝试了 pushViewControllerAnimatede:
  • popToviewController:动画:

我有Mac OSX 10.8.3,IOS 6,Xcode 4.5.2

我认为堆栈如何不维护但不知道如何????

1 个答案:

答案 0 :(得分:0)

我为singleView控制器使用了不同的xib,并在每个xib上应用按钮来推送和弹出它工作正常。我的代码显示如下: -

- (IBAction)pushToFourth:(id)sender {
    SPTViewController *viewController=[[SPTViewController alloc] initWithNibName:@"FourthView" bundle:nil];
    [self.navigationController pushViewController:viewController animated:YES];
}

- (IBAction)pushToThird:(id)sender {
    SPTViewController *viewController=[[SPTViewController alloc] initWithNibName:@"ThirdView" bundle:nil];
    [self.navigationController pushViewController:viewController animated:YES];
}

- (IBAction)pushtoSecond:(id)sender
{
    SPTViewController *viewController=[[SPTViewController alloc] initWithNibName:@"SecondView" bundle:nil];
    [self.navigationController pushViewController:viewController animated:YES];
}

- (IBAction)poptofirst:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
}

- (IBAction)poptosecond:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
}

- (IBAction)poptothird:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
}