【问题标题】:App stuck on Splash screen react-native-navigation应用程序卡在启动画面 react-native-navigation
【发布时间】: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


    【解决方案1】:

    您似乎正在尝试从处理程序启动应用程序。 你在RN 0.49 中是正确的,只有一个入口点,所以你应该从你的index.js 调用startSingleScreenApp,所以你的索引应该看起来像这样:

    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'});
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-01-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多