Skip to content

ios self.navigationController is nil #17095

@plimerence

Description

@plimerence

Is this a bug report?

(write your answer here)
Yes

Have you read the Contributing Guidelines?

(Write your answer here.)
NO

Environment

Environment:
OS: macOS Sierra 10.12.6
Node: 8.5.0
Yarn: 1.1.0
npm: 5.5.1
Watchman: 4.9.0
Xcode: Xcode 9.1 Build version 9B55
Android Studio: Not Found

Packages: (wanted => installed)
react: 16.0.0-beta.5 => 16.0.0-beta.5
react-native: 0.49.3 => 0.49.3

Steps to Reproduce

(Write your steps here:)

1.i put a rootView in a ios ViewController
2. i push Viewcontroller ,and RCT_EXPORT_MODULE()
3.but i can't pop back because self.navigationController is nil
RNViewController *webVC = [[RNViewController alloc] init]; NSURL *jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.bundle?platform=ios"]; RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL : jsCodeLocation moduleName : @"root" initialProperties : @{@"scores" : @[@{@"name" : @"Alex",@"value": @"42"},@{@"name" : @"Joel",@"value": @"10"}]} launchOptions: nil]; webVC.view = rootView; [self.navigationController pushViewController:webVC animated:YES];

RCT_EXPORT_MODULE() RCT_EXPORT_METHOD(pop) { dispatch_async(dispatch_get_main_queue(), ^{ // JFNavigationController *nav = [UIApplication sharedApplication].keyWindow.rootViewController.childViewControllers[4]; // [nav popViewControllerAnimated:YES]; [self.navigationController popViewControllerAnimated:YES]; }); }

Expected Behavior

i can pop back

(Write what you thought would happen.)

Actual Behavior

it can't pop back

(Write what happened. Add screenshots!)

i create a pure ViewController with of RCT_EXPORT_MODULE() and RCT_EXPORT_METHOD(pop),and i can get self.navigationController,it make me confuse ,what the RCT_EXPORT_MODULE() do ? where i can get my navigationController.

Reproducible Demo

(Paste the link to an example project and exact instructions to reproduce the issue.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Ran CommandsOne of our bots successfully processed a command.StaleThere has been a lack of activity on this issue and it may be closed soon.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions