我有反应原生0.40.0.react-native run-ios命令构建项目成功,但然后应用程序崩溃通知:服务退出由于中止陷阱:6!
我尝试通过点击它手动启动已安装的应用程序,但它在控制台中始终崩溃并出现相同的错误:
2月5日23:25:23 Tony com.apple.CoreSimulator.SimDevice.5050AC21-0E8E-4E59-9561-65AFF770E25A.launchd_sim [42289](UIKitApplication:org.reactjs.native.example.yawaloo [0x973d] [53112]):由于中止陷阱而退出服务:6
这就是全部,我甚至不知道在哪里看.也许是因为更新反应原生0.40?
有任何想法吗?
PS Android运行完美.
我正在为React Native iOS编写自定义视图.
基本上我必须使文本尽可能大(基于当前视图的视图).我已经通过覆盖reactSetFrame和更改框架来完成它.唯一的问题是视图的位置是错误的,这是一个截图:
似乎本地反应的"布局管理器"认为视图的高度为0.
这里的代码:
- (void)reactSetFrame:(CGRect)frame {
[super reactSetFrame:frame];
NSLog(@"react set frame %@", NSStringFromCGRect(frame));
[self fitText:self.text];
}
- (void)fitText:(NSString *)text {
// ... get the correct font size and expected size
[self setFont:font];
CGRect newFrame = self.frame;
newFrame.size.height = expectedLabelSize.height;
NSLog(@"new frame is %@", NSStringFromCGRect(newFrame));
self.frame = newFrame;
}
Run Code Online (Sandbox Code Playgroud)
基本上当帧发生变化时,我会根据传递的文本使用正确的维度更新帧.
日志输出如下:
2017-06-25 16:43:16.434 ABC[44836:6551225] react set frame {{0, 0}, {375, 0}}
2017-06-25 16:43:16.435 ABC[44836:6551225] new frame is {{0, 0}, {375, 69.197000000000017}}
2017-06-25 16:43:16.435 ABC[44836:6551225] react set …Run Code Online (Sandbox Code Playgroud) 我想添加accessibilityIdentifier一个React Native组件,以便我可以使用Xcode的UI测试来浏览我的应用程序.
有没有一种方法来指定accessibilityIdentifier(不是在accessibilityLabel为阵营母语)?
accessibility uiaccessibility react-native xcode-ui-testing react-native-ios
我们有一个本机反应项目,可以在模拟器和设备上正常运行。但是,我们无法使用iOS设备上的摇动手势打开开发人员菜单。
我看到了其他问题,但无法解决:https : //github.com/facebook/react-native/issues/5122
我们在Xcode中具有标准配置设置,因此可以使用调试方案进行构建。

但是,当摇晃设备时,我只是看起来很愚蠢,菜单没有显示。任何有关如何解决此问题的想法将不胜感激。
当用户选择语言时,我试图在运行时更改我的应用程序的语言。我正在尝试这样做
import I18n from 'react-native-i18n'
onChangeLanguage = () => {
console.log('String before change : >>> ', I18n.t('welcome'))
I18n.locale = 'hi'
console.log('String after change : >>> ', I18n.t('welcome'))
}
Run Code Online (Sandbox Code Playgroud)
在两个日志中,我得到了相同的 string 。我从这里参考。在此参考中,有一个使用 redux 的示例,但我的用例是使用 mobx。如果语言更改了如何重新渲染组件以反映语言更改。
android react-native mobx react-native-android react-native-ios
我想访问由我使用 react-native 创建的 ios 应用程序创建的领域数据库。它更容易adb pull用于 android 但对于 ios 我不太了解。有一些链接,如 -
所以任何帮助,如何查看领域数据库以开发和调试 react-native 开发的 ios 应用程序。
感谢您的回答,但额外的(出于好奇)问题 - 但如何找到通过 react native 在 ios 模拟器上安装的应用程序 uid ?
我正在使用andpor/react-native-sqlite-storage在 React Native 中管理 SQLite 数据库。现在我想将我的所有数据库备份到一个加密文件中,然后在以后恢复它。我知道如何在 android 中做到这一点,但不知道如何在 react native 中实现这一点。
如果它在android中,下面的代码可以帮助我在不加密的情况下备份数据库。
final String inFileName = "/data/data/<your.app.package>/databases/foo.db";
File dbFile = new File(inFileName);
FileInputStream fis = new FileInputStream(dbFile);
String outFileName = Environment.getExternalStorageDirectory()+"/database_copy.db";
// Open the empty db as the output stream
OutputStream output = new FileOutputStream(outFileName);
// Transfer bytes from the inputfile to the outputfile
byte[] buffer = new byte[1024];
int length;
while ((length = fis.read(buffer))>0){
output.write(buffer, 0, length);
}
// Close the streams
output.flush();
output.close();
fis.close();
Run Code Online (Sandbox Code Playgroud)
所以我的问题是如何在 React …
我是本机反应的新手,我正在尝试向我的 API 发送一些数据,基本上是一个 POST 请求,添加了一个按钮并尝试使用它来调用获取请求,但我不确定我做错了什么这个 ??它在日志中显示“请将方法附加到此组件”,如果我在这方面做错了什么,请告诉我?
这是我的按钮
<Button
style={{height: 60,width:150}}
onClick={ () => this.submitNewCustomer()}
title="SUBMIT"
backgroundColor='#C0C0C0'
color="black"
/>
Run Code Online (Sandbox Code Playgroud)
这是我的方法
submitNewCustomer(){
fetch('http://endpoint.net/api/customerdetail', {
method: 'POST',
headers: new Headers({
'Content-Type': 'application/json', // <-- Specifying the Content-Type
}),
body: JSON.stringify({
CustomerId: '1ef87a90-a941-4ebb-b101-66f74ac07778',
CustomerName: this.state.customername,
UserId:'user2',
VehicleCompanyName:this.state.vehiclecompanyname,
VehicleModelType:this.state.vehiclemodeltype,
VehicleNumber:this.state.vehiclenumber,
CustomerImage:'',
Location:'',
CustomerImageType:'png'
}), // <-- Post parameters
})
.then((response) => response.text())
.then((responseText) => {
alert(responseText);
})
.catch((error) => {
console.error(error);
});
}
Run Code Online (Sandbox Code Playgroud)
任何输入都会非常有帮助
我正在尝试使用 react native 元素和 react native 实现多行扩展文本输入,但我似乎无法让它正常运行。该行为显示在以下屏幕截图中:
正如你在这里看到的,文本有明显不止一行,但文本输入并没有展开。
每当我输入更多字符时,它都会扩展一点,但会向下扩展到键盘中。
添加另一行不会扩展键盘:
直到我添加更多字符,直到最新行是文本输入宽度的一半,输入才会展开
这是我用于文本输入的代码:
<View style={{flexDirection:'row', backgroundColor: 'transparent', height: Math.max(45, this.state.viewHeight)}}>
<Input
containerStyle={{marginVertical: 0, width:300, marginLeft: 10}}
inputStyle={[styles.textInput, {height: Math.max(35, this.state.height)}]}
multiline
enablesReturnKeyAutomatically={true}
keyboardAppearance="dark"
placeholder=""
onContentSizeChange={(event) => {
if (this.state.height <= (35*6)){
this.setState({
height: event.nativeEvent.contentSize.height,
viewHeight: event.nativeEvent.contentSize.height })
}
}}
onChangeText={(message) => { this.setState({message})
}}
Run Code Online (Sandbox Code Playgroud)
这是我的文本输入样式的代码:
textInput: {
paddingHorizontal: 12,
width: 100,
backgroundColor: '#F0F0F0',
borderStyle: 'solid',
marginLeft: -4,
overflow: 'hidden',
marginTop: 5,
borderWidth: 1,
borderColor: 'lightgrey',
borderRadius: 25,
},
Run Code Online (Sandbox Code Playgroud)
似乎内容大小更改事件在错误的时间触发,有什么方法可以将其设置为仅在新行具有特定长度并向上扩展而不是向下扩展到键盘时触发?
我已经集成了 React Native 导航包。我想在我的 topBar rightButton 上添加带有动态值的徽章。包的 Github 链接::https : //github.com/wix/react-native-navigation
我想要这样的输出。您可以查看此屏幕截图::
问题::
如果我在通知图标上添加计数值,那么当我尝试单击按钮时不会发生任何事件。单击此按钮后,我想打开通知屏幕。
代码:
static options({ menuIcon }) {
return {
topBar: {
title: {
fontFamily: font,
fontSize: fontSize.heading,
color: colors.white,
alignment: 'center',
text: strings.dashboard
},
alignment: 'center',
elevation: 0,
noBorder: true,
background: {
color: colors.dark
},
leftButtons: [
{
id: 'openSideMenu',
icon: menuIcon ? menuIcon : APIURLServiceSingleton.getInstance()._menuIcon
}
],
rightButtons: [
{
id: 'notificationButton',
component: {
name: 'component.notificationButton'
}
}
]
}
}
}
Run Code Online (Sandbox Code Playgroud)
我的自定义组件的代码::
<TouchableOpacity
onPress={() …Run Code Online (Sandbox Code Playgroud) react-native ×10
react-native-ios ×10
ios ×2
android ×1
fetch ×1
javascript ×1
mobx ×1
realm ×1
sqlite ×1
textinput ×1