2015-08-26 113 views
0

** **在Discover.mpushViewController不是的.xib文件工作

AgendaListPage *controller1 = [[AgendaListPage alloc]initWithNibName:@"AgendaListPage" bundle:nil]; 
    controller1.title = @"Page1"; 
    MissedDataListPage *controller2 = [[MissedDataListPage alloc]initWithNibName:@"MissedDataListPage" bundle:nil]; 
    controller2.title = @"Page2"; 

** **在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>.

编辑:

enter image description here

enter image description here

+0

'self.navigationController'零? – Larme

+0

是的,你是权利self.navigationController是零我该如何解决?我编辑问题 – vayfi

+0

当您创建AgendaListPage的对象时,您应该以编程方式将AgendaListPage控制器添加到导航控制器。例如'AgendaListPage * obj = [[AgendaListPage alloc] init]; 的UINavigationController * navController = [UINavigationController的页头] initWithRootViewController:OBJ;” –

回答

0

对于厦门国际银行则不需要创建故事板对象

只是控制器的alloc初始化工作

HastagScreenTablePage *myControllerHastag = [[HastagScreenTablePage alloc]init]; 
[self.navigationController pushViewController:myControllerHastag animated:YES]; 
0

你没有在你的故事板添加导航控制器。对?如果是这样,你会得到“self.navigation == nil”。首先添加导航控制器,然后设置一个根视图控制器。然后你的pushViewController将得到它的实例并工作。

+0

'HastagScreenTablePage * bbp = [[HastagScreenTablePage alloc] initWithNibName:@“Main”bundle:nil]; UINavigationController * passcodeNavigationController = [[UINavigationController alloc] initWithRootViewController:bbp]; [self.navigationController pushViewController:passcodeNavigationController animated:YES];'像这样? – vayfi

+0

右键单击并从导航控制器拖动到YourFirstViewController,然后您会看到许多选项。然后选择“根视图控制器” – Jamil

+0

但我使用.xib我怎么能在.xib中做到这一点? – vayfi

0

确保您在故事板文件中为UIViewController设置标识符('hastagScreen'在您的案例中),可能是以下代码返回nil。

HastagScreenTablePage *myControllerHastag = [self.storyboard instantiateViewControllerWithIdentifier:@"hastagScreen"]; // myControllerHastag might be nil. 

replace YOUR_ID with hastagScreen

+0

HastagScreenTablePage没有viewController Discover.m中的addSubview检查图像 – vayfi

+0

http://imgur.com/P4hOv1K – vayfi

+0

'instantiateViewControllerWithIdentifier'会给你一个viewcontroller对象,你将它分配给'HastagScreenTablePage'(“HastagScreenTablePage还没有viewController”),我假设是一个'UIView',它的所有错误 – Saif

相关问题