2017-10-17 40 views
1

我根据react-native-navigation上的示例更改AppDelegate.m文件。我将index.ios更改为index,因为反应原生不会再生成index.ios文件。应用程序卡在Splash屏幕上react-native-navigation

jsCodeLocation =[[RCTBundleURLProvidersharedSettings]jsBundleURLForBundleRoot:@"index" fallbackResource:nil];

#import "AppDelegate.h" 
#import <React/RCTBundleURLProvider.h> 
#import "RCCManager.h" 
#import <React/RCTRootView.h> 

@implementation AppDelegate 

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    NSURL *jsCodeLocation; 
#ifdef DEBUG 
    jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil]; 
#else 
    jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; 
#endif 
    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 
    self.window.backgroundColor = [UIColor whiteColor]; 
    [[RCCManager sharedInstance] initBridgeWithBundleURL:jsCodeLocation launchOptions:launchOptions]; 
    return YES; 
} 
@end 

现在应用程序被卡住开机画面上显示的项目名称及以下技术的反应本地人。

function onPressLearnMore() { 

    Navigation.startSingleScreenApp({ 
    screen: { 
     screen: 'app.screens.HomeScreen', // unique ID registered with Navigation.registerScreen 
     title: 'Welcome', // title of the screen as appears in the nav bar (optional) 
     navigatorStyle: {}, // override the navigator style for the screen, see "Styling the navigator" below (optional) 
     navigatorButtons: {} // override the nav buttons for the screen, see "Adding buttons to the navigator" below (optional) 
    }, 
    passProps: {}, // simple serializable object that will pass as props to all top screens (optional) 
    animationType: 'slide-down' // optional, add transition animation to root change: 'none', 'slide-down', 'fade' 
    }); 
    console.log("Hello"); 
} 

环境

react-native-cli: 2.0.1 
react-native: 0.49.3 

回答

0

好像你正试图从启动处理程序的应用程序。 您在RN 0.49说得有一个单一入口点,所以你应该叫startSingleScreenAppindex.js,所以你的指数应类似于此:

import {Navigation} from 'react-native-navigation'; 
import {registerScreens} from './screens'; 

registerScreens(); 
Navigation.startSingleScreenApp({ 
screen: { 
    screen: 'app.screens.HomeScreen', // unique ID registered with Navigation.registerScreen 
    title: 'Welcome', // title of the screen as appears in the nav bar (optional) 
    navigatorStyle: {}, // override the navigator style for the screen, see "Styling the navigator" below (optional) 
    navigatorButtons: {} // override the nav buttons for the screen, see "Adding buttons to the navigator" below (optional) 
}, 
passProps: {}, // simple serializable object that will pass as props to all top screens (optional) 
animationType: 'slide-down' // optional, add transition animation to root change: 'none', 'slide-down', 'fade'}); 
相关问题