2015-08-26 77 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

相關問題