【问题标题】:how to solve back button error in ios 7?如何解决ios 7中的后退按钮错误?
【发布时间】:2014-05-21 06:55:50
【问题描述】:

当我点击返回按钮然后控制器返回菜单但应用程序崩溃?

       -(void)launchselfEvalutionFromPresidentDetailViewController
        {
            Self_Evalution_Page *self_page=[[Self_Evalution_Page alloc]initWithNibName:@"Self_Evalution_Page" bundle:nil];

            [self.navigationController pushViewController:self_page animated:YES];

        }

    - (void)viewDidLoad
    {
        [super viewDidLoad];
        // Do any additional setup after loading the view from its nib.
        self.pageController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:nil];

        self.pageController.dataSource = self;
        [[self.pageController view] setFrame: CGRectMake(0,[topBar bottom] + 5,320,500)];


        SelfEvalutionTableView *selfObj=[self viewControllerAtIndex:0];


        NSArray *viewControllers = [NSArray arrayWithObject:selfObj];

        [self.pageController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];

        [self addChildViewController:self.pageController];
        [[self view] addSubview:[self.pageController view]];
        [self.pageController didMoveToParentViewController:self];

    }

我使用此代码向前移动。但我单击后退按钮应用程序崩溃。

【问题讨论】:

  • 错误信息是什么?
  • 当我点击后退按钮时,应用程序挂在左侧菜单上。
  • 那没有给出错误信息。看看调试器,错误信息是什么样的? EXC_BAD_ACCESS?也许启用 NSZOmbies 以获得更清晰的信息?从我看来,您的代码似乎可以编译。但是,这将有助于告诉我们是哪条线路导致了问题......
  • 我有导航后退按钮。我创建了 UIpageviewcontroller。当我点击后退按钮时,控制器移回 privious 视图,但控制器转到菜单并挂在同一页面上。日志中没有错误消息。
  • 如何取消返回按钮

标签: iphone ios7 uinavigationcontroller


【解决方案1】:

尝试在您的后退按钮按下事件或代码中使用它。

[self dismissViewControllerAnimated:YES completion:nil];

希望这会有所帮助。

【讨论】:

    【解决方案2】:

    自定义您的后退按钮操作,试试下面的代码

     UIImage *buttonImage = [UIImage imageNamed:@"backBtn.png"];
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        [button setImage:buttonImage forState:UIControlStateNormal];
        button.frame = CGRectMake(0, 0, 25, 25);
        [button addTarget:self action:@selector(GoBack) forControlEvents:UIControlEventTouchUpInside];
        UIBarButtonItem *customBarItem = [[UIBarButtonItem alloc] initWithCustomView:button];
        self.navigationItem.leftBarButtonItem = customBarItem;
        [customBarItem release];
    

    调用这个函数

    -(IBAction)GoBack
    {
        [self.navigationController popViewControllerAnimated:YES];
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-09-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-25
      相关资源
      最近更新 更多