iPhone:导航栏按钮无限期地链接到它自己的视图

发布于 2024-08-30 21:35:30 字数 3343 浏览 2 评论 0原文

当我从根视图导航到另一个视图时,它起作用了。然而,当我想返回时,导航按钮会链接到自身。这会持续大约 6 次点击,直到最终返回到根视图。

这只发生在一个视图上,其余的都工作正常。

我不知道是什么代码导致了这个问题,但是如果您需要任何代码,我将用它修改这篇文章。就问吧。

多谢, 杰克。

推送视图(在 rootviewcontroller.m 中)

在 didSelectRowAtIndexPath 方法中

  - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    //CSS
    if ([[arryClientSide objectAtIndex:indexPath.row] isEqual:@"CSS"])
    {
        CSSViewController *css = [[CSSViewController alloc] initWithNibName:@"CSSViewController" bundle:nil];
        [css setTitle:@"CSS"];
        [self.navigationController pushViewController:css animated:YES];
    }

    //HTML
    if ([[arryClientSide objectAtIndex:indexPath.row] isEqual:@"HTML"])
    {
        HTMLViewController *html = [[HTMLViewController alloc] initWithNibName:@"HTMLViewController" bundle:nil];
        [html setTitle:@"HTML"];
        [self.navigationController pushViewController:html animated:YES];
    }


    //Apache
    if ([[arryServerSide objectAtIndex:indexPath.row] isEqual:@"Apache"])
    {
        ApacheViewController *apache = [[ApacheViewController alloc] initWithNibName:@"ApacheViewController" bundle:nil];
        [apache setTitle:@"Apache"];
        [self.navigationController pushViewController:apache animated:YES];
    }

    //JS
    if ([[arryClientSide objectAtIndex:indexPath.row] isEqual:@"JavaScript"])
    {
        JSViewController *js = [[JSViewController alloc] initWithNibName:@"JSViewController" bundle:nil];
        [js setTitle:@"JavaScript"];
        [self.navigationController pushViewController:js animated:YES];
    }

    //PHP
    if ([[arryServerSide objectAtIndex:indexPath.row] isEqual:@"PHP"])
    {
        PHPViewController *php = [[PHPViewController alloc] initWithNibName:@"PHPViewController" bundle:nil];
        [php setTitle:@"PHP"];
        [self.navigationController pushViewController:php animated:YES];
    }

    //SQL
    if ([[arryServerSide objectAtIndex:indexPath.row] isEqual:@"SQL"])
    {
        SQLViewController *sql = [[SQLViewController alloc] initWithNibName:@"SQLViewController" bundle:nil];
        [sql setTitle:@"SQL"];
        [self.navigationController pushViewController:sql animated:YES];
    }

    //HTML Colour Codes
    if ([[arryResources objectAtIndex:indexPath.row] isEqual:@"HTMLColourCodes"])
    {
        HTMLColourViewController *htmlcol = [[HTMLColourViewController alloc] initWithNibName:@"HTMLColourViewController" bundle:nil];
        [htmlcol setTitle:@"Colours"];
        [self.navigationController pushViewController:htmlcol animated:YES];
    }

    //Useful Resources
    if ([[arryResources objectAtIndex:indexPath.row] isEqual:@"Useful Resources"])
    {
        UsefulViewController *useful = [[UsefulViewController alloc] initWithNibName:@"UsefulViewController" bundle:nil];
        [useful setTitle:@"Resources"];
        [self.navigationController pushViewController:useful animated:YES];
    }

    //About
    if ([[arryResources objectAtIndex:indexPath.row] isEqual:@"About"])
    {
        AboutViewController *about = [[AboutViewController alloc] initWithNibName:@"AboutViewController" bundle:nil];
        [about setTitle:@"About"];
        [self.navigationController pushViewController:about animated:YES];
    }

When I navigate from the root view to another view, it works. However, when I want to get back, the navigation button links to itself. This goes on for about 6 taps, until it eventually goes back to the root view.

This only occurs on one view, and the rest are working fine.

I have no idea what code is causing this, but if you need any code, I will amend this post with it. Just ask for it.

Thanks a lot,
Jack.

Pushing the view (in rootviewcontroller.m)

In didSelectRowAtIndexPath method

  - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    //CSS
    if ([[arryClientSide objectAtIndex:indexPath.row] isEqual:@"CSS"])
    {
        CSSViewController *css = [[CSSViewController alloc] initWithNibName:@"CSSViewController" bundle:nil];
        [css setTitle:@"CSS"];
        [self.navigationController pushViewController:css animated:YES];
    }

    //HTML
    if ([[arryClientSide objectAtIndex:indexPath.row] isEqual:@"HTML"])
    {
        HTMLViewController *html = [[HTMLViewController alloc] initWithNibName:@"HTMLViewController" bundle:nil];
        [html setTitle:@"HTML"];
        [self.navigationController pushViewController:html animated:YES];
    }


    //Apache
    if ([[arryServerSide objectAtIndex:indexPath.row] isEqual:@"Apache"])
    {
        ApacheViewController *apache = [[ApacheViewController alloc] initWithNibName:@"ApacheViewController" bundle:nil];
        [apache setTitle:@"Apache"];
        [self.navigationController pushViewController:apache animated:YES];
    }

    //JS
    if ([[arryClientSide objectAtIndex:indexPath.row] isEqual:@"JavaScript"])
    {
        JSViewController *js = [[JSViewController alloc] initWithNibName:@"JSViewController" bundle:nil];
        [js setTitle:@"JavaScript"];
        [self.navigationController pushViewController:js animated:YES];
    }

    //PHP
    if ([[arryServerSide objectAtIndex:indexPath.row] isEqual:@"PHP"])
    {
        PHPViewController *php = [[PHPViewController alloc] initWithNibName:@"PHPViewController" bundle:nil];
        [php setTitle:@"PHP"];
        [self.navigationController pushViewController:php animated:YES];
    }

    //SQL
    if ([[arryServerSide objectAtIndex:indexPath.row] isEqual:@"SQL"])
    {
        SQLViewController *sql = [[SQLViewController alloc] initWithNibName:@"SQLViewController" bundle:nil];
        [sql setTitle:@"SQL"];
        [self.navigationController pushViewController:sql animated:YES];
    }

    //HTML Colour Codes
    if ([[arryResources objectAtIndex:indexPath.row] isEqual:@"HTMLColourCodes"])
    {
        HTMLColourViewController *htmlcol = [[HTMLColourViewController alloc] initWithNibName:@"HTMLColourViewController" bundle:nil];
        [htmlcol setTitle:@"Colours"];
        [self.navigationController pushViewController:htmlcol animated:YES];
    }

    //Useful Resources
    if ([[arryResources objectAtIndex:indexPath.row] isEqual:@"Useful Resources"])
    {
        UsefulViewController *useful = [[UsefulViewController alloc] initWithNibName:@"UsefulViewController" bundle:nil];
        [useful setTitle:@"Resources"];
        [self.navigationController pushViewController:useful animated:YES];
    }

    //About
    if ([[arryResources objectAtIndex:indexPath.row] isEqual:@"About"])
    {
        AboutViewController *about = [[AboutViewController alloc] initWithNibName:@"AboutViewController" bundle:nil];
        [about setTitle:@"About"];
        [self.navigationController pushViewController:about animated:YES];
    }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文