【发布时间】:2015-08-26 11:29:56
【问题描述】:
** 在 ** Discover.m 中
AgendaListPage *controller1 = [[AgendaListPage alloc]initWithNibName:@"AgendaListPage" bundle:nil];
controller1.title = @"Page1";
MissedDataListPage *controller2 = [[MissedDataListPage alloc]initWithNibName:@"MissedDataListPage" bundle:nil];
controller2.title = @"Page2";
** In ** AgendaListPage.m
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
if (tableView == self.tableView){
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle: nil];
HastagScreenTablePage *myControllerHastag = [storyboard instantiateViewControllerWithIdentifier:@"hastagScreen"];
myControllerHastag.detailModalForHastag = @[[getTopHastagObject[indexPath.row] gethastagName]];
[self.navigationController pushViewController: myControllerHastag animated:YES];
}
}
我使用https://github.com/uacaps/PageMenu API Obj-C 版本。
我尝试了所有方法,但在选择行时页面不会改变。有什么想法吗?
编辑:
我这样修改代码
HastagScreenTablePage *myControllerHastag = [self.storyboard instantiateViewControllerWithIdentifier:@"hastagScreen"];
myControllerHastag.detailModalForHastag = @[[getTopHastagObject[indexPath.row] gethastagName]];
FirstNavControllerPage *navigationController = [[FirstNavControllerPage alloc] initWithRootViewController:myControllerHastag];
[self.navigationController pushViewController: navigationController animated:YES];
FirstNavControllerPage 是一个 UINavigationController
现在错误:Application tried to push a nil view controller on target <FirstNavControllerPage: 0x13659d5c0>.
编辑:
【问题讨论】:
-
self.navigationControllernil? -
是的,你是正确的 self.navigationController 是 nil 我该如何解决?我编辑问题
-
您应该在创建 AgendaListPage 对象时以编程方式将 AgendaListPage 控制器添加到导航控制器。例如'AgendaListPage *obj = [[AgendaListPage alloc]init]; UINavigationController *navController = [UINavigationController alloc]initWithRootViewController:obj;'
-
HastagScreenTablePage *myControllerHastag = [self.storyboard instantiateViewControllerWithIdentifier:@"hastagScreen"]; myControllerHastag.detailModalForHastag = @[[getTopHastagObject[indexPath.row] gethastagName]]; FirstNavControllerPage *navigationController = [[FirstNavControllerPage alloc] initWithRootViewController:myControllerHastag]; [self.navigationController pushViewController: navigationController animated:YES];我这样改代码还是不行 -
不,我说的是 HastagScreenTablePage,我说的是我认为的当前控制器,即 AgendaListPage 你应该在 Navigationcontroller 中添加这个 AgendaListPage 控制器
标签: ios objective-c storyboard pushviewcontroller