【发布时间】:2017-10-17 12:57:10
【问题描述】:
我根据 react-native-navigation 上的示例更改了 AppDelegate.m 文件。我将 index.ios 更改为 index 因为 react native 不再生成 index.ios 文件。
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
现在应用卡在显示项目名称的初始屏幕和下方由 react native 提供支持。
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
【问题讨论】:
标签: ios react-native react-native-navigation