簡體   English   中英

從tableview移到情節提要的另一個uiviewcontroller

[英]moving from tableview to another uiviewcontroller of the storyboard

當按表格視圖的一行時,我想在情節提要的另一個屏幕中移動。

1)我不想使用導航控制器,還是必須?

所以我嘗試了這段代碼:

UIStoryboard * storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];

UIViewController *vc=[storyBoard instantiateViewControllerWithIdentifier:@"CenterMain"];
    [vc setModalPresentationStyle:UIModalPresentationFullScreen];
    [self presentedViewController:vc animated:YES];

在我的(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

我收到此警告:

Instance method '-presentedViewController:animated:' not found (return type defaults to 'id')

並且在運行時出現此錯誤:

MainMap presentedViewController:animated:]: unrecognized selector sent to instance 0x72a2070
 *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MainMap presentedViewController:animated:]: unrecognized selector sent to instance 0x72a2070'

2)如果使用帶有以下代碼的navigationController:

UIStoryboard * storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
[[self navigationController] pushViewController:[storyBoard instantiateViewControllerWithIdentifier:@"CenterMain"] animated:YES];

它可以工作,但問題是我不想在頂部看到導航控制器的欄。

因此,我想與1混合使用,或者告訴我如何在解決方案2中擦除頂部的條。

謝謝!

使用UIViewController - (void)setNavigationBarHidden:(BOOL)hidden animated:(BOOL)animated- (void)setNavigationBarHidden:(BOOL)hidden; 方法。 所以就你而言

[[self navigationController] setNavigationBarHidden:YES];

如果您只想隱藏它,或者:

[[self navigationController] setNavigationBarHidden:YES animated:YES];

如果要在隱藏時進行動畫處理。

暫無
暫無

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

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