Oma*_*nik 7 wix-react-native-navigation react-native-navigation-v2
反应原生导航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
};
Run Code Online (Sandbox Code Playgroud)
屏幕注册:
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
};
Run Code Online (Sandbox Code Playgroud)
ENV:
"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"
},
Run Code Online (Sandbox Code Playgroud)
Red*_*ant 19
我在V2中遇到了类似的问题,问题是由于没有删除didFinishLaunchingWithOptionsAppDelegate.m 中方法中的rootView设置.
- (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;
}
Run Code Online (Sandbox Code Playgroud)
如果您将它们留在,则会导致应用程序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;
}
Run Code Online (Sandbox Code Playgroud)
我也遇到了同样的问题,但仅限于 Android。事实证明我错过了配置过程中的一个步骤。
在 MainActivity.java 中,它应该扩展 com.reactnativenavigation.NavigationActivity 而不是 ReactActivity。
https://wix.github.io/react-native-navigation/v2/#/docs/Installing。
| 归档时间: |
|
| 查看次数: |
7073 次 |
| 最近记录: |