gpt4 book ai didi

wix-react-native-navigation - 应用程序尚未注册(react-native-navigation v2)

转载 作者:行者123 更新时间:2023-12-04 09:23:19 26 4
gpt4 key购买 nike

react 原生导航 v2 问题。

我的应用程序以 index.js 开头,它也注册到 AppDelegate 中。以下是详细信息:

import { AppRegistry } from 'react-native';
const { start } = require('./src/app');
start();

这里app.js:

```

const { Navigation } = require('react-native-navigation');
const { registerScreens } = require('./screens');
const { Platform } = require('react-native');

if (Platform.OS === 'android') {
alert = (title) => {
Navigation.showOverlay({
component: {
name: 'navigation.playground.alert',
passProps: {
title
},
options: {
overlay: {
interceptTouchOutside: true
}
}
}
});
};
}

function start() {
registerScreens();
Navigation.events().registerAppLaunchedListener(() => {
Navigation.setDefaultOptions({
_animations: {
startApp: {
y: {
from: 1000,
to: 0,
duration: 500,
interpolation: 'accelerate',
},
alpha: {
from: 0,
to: 1,
duration: 500,
interpolation: 'accelerate'
}
},
push: {
topBar: {
id: 'TEST',
alpha: {
from: 0,
to: 1,
duration: 500,
interpolation: 'accelerate'
}
},
bottomTabs: {
y: {
from: 1000,
to: 0,
duration: 500,
interpolation: 'decelerate',
},
alpha: {
from: 0,
to: 1,
duration: 500,
interpolation: 'decelerate'
}
},
bottomTabs: {
y: {
from: 1000,
to: 0,
duration: 500,
interpolation: 'decelerate',
},
alpha: {
from: 0,
to: 1,
duration: 500,
interpolation: 'decelerate'
}
},
content: {
y: {
from: 1000,
to: 0,
duration: 500,
interpolation: 'accelerate',
},
alpha: {
from: 0,
to: 1,
duration: 500,
interpolation: 'accelerate'
}
}
},
pop: {
topBar: {
id: 'TEST',
alpha: {
from: 1,
to: 0,
duration: 500,
interpolation: 'accelerate'
}
},
bottomTabs: {
y: {
from: 0,
to: 100,
duration: 500,
interpolation: 'accelerate',
},
alpha: {
from: 1,
to: 0,
duration: 500,
interpolation: 'accelerate'
}
},
bottomTabs: {
y: {
from: 0,
to: 100,
duration: 500,
interpolation: 'decelerate',
},
alpha: {
from: 1,
to: 0,
duration: 500,
interpolation: 'decelerate'
}
},
content: {
y: {
from: 0,
to: 1000,
duration: 500,
interpolation: 'decelerate',
},
alpha: {
from: 1,
to: 0,
duration: 500,
interpolation: 'decelerate'
}
}
}
}
});

Navigation.setRoot({
root: {
stack: {
id: 'TEST',
children: [
{
component: {
name: 'rp.welcome'
}
}
]
}
}
});
});
}


module.exports = {
start
};

屏幕注册:
const { Navigation } = require('react-native-navigation');
const WelcomeScreen = require('./WelcomeScreen');
const Authentication = require('./Authentication').default;
const Tutorial = require('./Tutorial');

function registerScreens() {
Navigation.registerComponent(`rp.welcome`, () => WelcomeScreen);
Navigation.registerComponent(`rp.tutorial`, ()=>Tutorial);
Navigation.registerComponent(`rp.authentication.super`,()=> Authentication);
}

module.exports = {
registerScreens
};

环境:
"dependencies": {
"react": "16.3.1",
"react-native": "0.55.4",
"react-native-navigation": "^2.0.2314",
"react-native-video": "^2.1.1",
"rn-viewpager": "^1.2.9"
},

最佳答案

我在 V2 中也遇到过类似的问题,问题是由于没有删除 didFinishLaunchingWithOptions 中的 rootView 设置引起的。 AppDelegate.m 中的方法

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

NSURL *jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
[ReactNativeNavigation bootstrap:jsCodeLocation launchOptions:launchOptions];


RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"XXXXXXXXXX"
initialProperties:nil
launchOptions:launchOptions];
rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];

self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIViewController *rootViewController = [UIViewController new];
rootViewController.view = rootView;
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];

return YES;
}

如果你把它们留在里面, 会导致 Application XXXXXXXXXX 未注册错误 . https://wix.github.io/react-native-navigation/v2/#/docs/Installing中的IOS说明应该强调的是,必须删除这些与 rootView 相关的行。

正确的 AppDelegates.m 应该是这样的:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

NSURL *jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
[ReactNativeNavigation bootstrap:jsCodeLocation launchOptions:launchOptions];

return YES;
}

关于wix-react-native-navigation - 应用程序尚未注册(react-native-navigation v2),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50683866/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com