简体   繁体   中英

moving from tableview to another uiviewcontroller of the storyboard

when pressing a row of the table view I want to move in another screen of my storyboard.

1) I do not want to use navigation controller, or do i have to?

So I tried this code:

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

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

inside my (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

I am getting this warning:

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

and this error when running:

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) If using navigationController with this code:

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

it works but the thing is that I do not want to see the bar of the navigation controller on the top.

So I want either to helo with the 1, or tell how to erase the top bar in sollution 2.

Thanks!

Use the UIViewController - (void)setNavigationBarHidden:(BOOL)hidden animated:(BOOL)animated or - (void)setNavigationBarHidden:(BOOL)hidden; method. So in your case,

[[self navigationController] setNavigationBarHidden:YES];

if you just want it hidden, or:

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

if you want to animate while hiding.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM