2017-10-17 36 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'}); 
相關問題