iPhone:导航栏按钮无限期地链接到它自己的视图
当我从根视图导航到另一个视图时,它起作用了。然而,当我想返回时,导航按钮会链接到自身。这会持续大约 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论