簡體   English   中英

從添加為子視圖的View Controller加載新的View Controller

[英]Load new View Controller from View Controller added as a subview

嗨,我在我的項目https://github.com/firebaseco/FireUIPagedScrollView中使用以下庫我已經添加了一些視圖控制器作為頁面。 現在的問題是,當用戶在我的一個視圖控制器中選擇一個按鈕作為頁面加載時,該頁面將簡單地替換為我的新視圖控制器,而不是持有這些頁面的視圖控制器。 任何人都知道當在頁面之一上按下某些內容時如何才能轉移到全新的視圖控制器嗎?

我用來從頁面加載其他視圖尋呼機的代碼如下

    WebViewController *dvController = [[WebViewController alloc] initWithNibName:@"WebViewController" bundle:[NSBundle mainBundle]];
    dvController.url = url;
    UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:dvController];
    nc.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
    [self presentModalViewController:nc animated:YES];

任何幫助將不勝感激

一個簡單的解決方案最終是在頁面中創建屬性,並在添加了頁面的ViewController中進行設置

在Page.h中

@property (nonatomic, retain) UINavigationController *navController;

在Page Holding View Controller中,將屬性設置為等於holders navigationController

Page  *pageVC = [[Page alloc] initWithNibName:@"Page" bundle:nil];
pageVC.navController = self.navigationController;

然后在Page.m中,當我想推送新的View Controller時,在推送新的View Controller時僅使用了現在設置的屬性

@synthesize navController
...
NewViewController *dvController = [[NewViewController alloc] initWithNibName:@"NewViewController" bundle:[NSBundle mainBundle]];
[self.navController pushViewController:dvController animated:NO];

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM