为什么self.navigationController pushViewController不工作?
我有一个为什么self.navigationController pushViewController不工作?
UIViewController-> UINavigationBar的+的UITableView
只是有点更多的解释
我通过UIBuilder做吧..
1:创建一个新的UIViewController
with XIB-file
2:使用UIBuiler
我把UINavigationController
3:后来我把UITableView
的navigationBar
所以它给了我下面..
答:UIViewController-> UINavigationBar的+的UITableView
现在我已经从正在工作的Web服务加载UITableView中的数据。
我再次由具有SAM配置一个XIB是
B:UIViewController-> UINavigationBar的+的UITableView
所以,现在,当我尝试使用以下代码对视图A推视图B中。 ..它惯于在所有的工作......
SelectSiteViewController *siteViewController = [[SelectSiteViewController alloc] initWithNibName:@"SelectSiteViewController" bundle:nil];
[self.navigationController pushViewController:siteViewController animated:YES];
当我检查了UINavigationController *nav = self.navigation
nav是0x0,我假设为NIL。
谁能告诉我什么是错在这里..为什么是零...我怎样才能使它工作..
非常感谢....我真的很感谢所有帮助
在UIBuilder中,验证UINavigationController是由文件所有者引用的。
所以,你要添加tableview到导航控制器的权利?这是如何:
tableView = [[UITableViewController alloc] initWithStyle:UITableViewStylePlain];
navigationController = [[UINavigationController alloc] init];
[navigationController pushViewController:tableView animated:NO];
tableview作为rootview添加到导航控制器。再上,如果你想推另一个视图 - 控制选择行使用
self.navigationController pushViewController: newViewController animated:YES];
的didSelectRowAtIndex方法内。
注意:它的UITableViewController * tableView和UINavigationController * navigationController是声明的。所以相应地为你的表编码。
否否... 我创建了一个新文件,它是带有XIB选项Selected的UIViewController。用于离: @interface ClasssName:的UIViewController { } 所以它的UIViewController 的一个子类 现在我打开XIB文件拖放UINavigationBar的 然后我下降的UITableView到XIB文件是UIViewController中 这有帮助吗? – ujwaltrivedi 2010-11-19 14:28:01
明白了。
我改变了建筑的一点点。
我用它的xib创建了一个新的UIViewController类。并编写新的UINavigationController。
- (void)viewDidLoad {
[super viewDidLoad];
UINavigationController *navigationController
navigationController = [[UINavigationController alloc] init];
[self.view addSubview:navigationController.view];
switch (whichViewController) {
case 1:
viewController = [[xxxx alloc] init];
break;
case 2:
viewController = [[xxx1 alloc] init];
break;
default:
break;
}
[navigationController pushViewController:viewController animated:NO];
[viewController release];
}
,推动在switch语句中的视图....
我希望这是有道理的......
感谢jamihash
为什么UIViewController-> UINavigationBar + UITableView?
我建议你另一种方法 - >的UITableViewController A - >与导航控制器的嵌入式,然后填充tableview中后,你可以将数据传递给 - 由 >的UITableViewController B [[自我情节提要] instantiateViewControllerWithIdentifier:@ “ControllerB”] ;
然后,在故事板中,放置一个tableView B并在Identity-> storyboard Id中放置一些id。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *sUrl= @"<#string#>";
if (indexPath.row == 0) sUrl= @"http://www.apple.com/";
if (indexPath.row == 1) sUrl= @"http://www.google.com/";
if (indexPath.row == 2) sUrl= @"http://www.times.uk/";
NSMutableArray *selectedObject = [arrayOpenMale objectAtIndex:0];
NSLog(@"%@ is the selected object.",selectedObject);
SeriesAdetailVC *dvc = [[self storyboard]instantiateViewControllerWithIdentifier:@"DetailView"];
dvc.strings7 = [NSURL URLWithString:sUrl];
[self.navigationController pushViewController:dvc animated:YES];
}
希望帮助
当你把从UIBuilder库UINavigationBar的是一个UINavigationController?这是一个UINavigationBar。 – ujwaltrivedi 2010-11-19 14:23:46
它只是在视图中出现的酒吧。您需要在UIBuilder中拖放UINavigationController并将其挂接到文件所有者的导航控制器。或者你可以在代码中创建。 – jamihash 2010-11-20 04:43:18
嘿,我可以给你的代码....我试过,但无法弄清楚......我真的很感激任何帮助...谢谢你 – ujwaltrivedi 2010-11-20 23:10:02