React Native踩坑Tip
最近在使用React Native(以下简称RN)中踩了个坑,RN只能异步调用原生方法,所以在原生方法直接调用UI刷新操作需要将任务递交到主线程才可以。
RCT_EXPORT_METHOD(finish)
{
UIViewController *cVC = [UIViewController getTopViewController];
[cVC.navigationController popViewControllerAnimated:YES];
}
调用的时候可以发现,线程并不是主线程。比如我这次是在thread 13
提交到主线程就可以
RCT_EXPORT_METHOD(finish)
{
dispatch_async(dispatch_get_main_queue(), ^{
UIViewController *cVC = [UIViewController CM_curViewController];
[cVC.navigationController popViewControllerAnimated:YES];
});
}
React Native踩坑Tip的更多相关文章
- React Native踩坑日记 —— tailwind-rn
项目背景 在项目的初始阶段,我们需要建立自己的design system,我们spike了一些方案,tailwind-rn就是其中一种,如果有用到或者即将用到tailwind-rn的,可以进来看一看, ...
- React Native踩坑之旅
原文连接:http://www.studyshare.cn/blog-front/blog/details/1137 最近做一个app,使用React Native实现,如果严格按照RN官方文档去配置 ...
- react Native 踩坑记录
应用 1 安卓打包 经验 解决方案 ,官方 解决方案 2 调试 用 React-Native-Debugger 教程 3 微信分享和登录 使用 react-native-wechat 地址 设计 ...
- React Native踩坑之FlatList组件中的onEndReached
最近在做一个RN项目,有使用到FlatList这样一个RN封装的组件去做上拉加载更多功能,在iOS和Android平台上,总结了以下几个遇到的问题及解决方案 1. 进入页面onReached开始就被触 ...
- React Native踩坑之The SDK directory 'xxxxx' does not exist
相信和我一样,自己摸索配置环境的过程中,第一次配,很可能就遇到了这个比较简单地错误,没有配置sdk环境 解决办法 在电脑,系统环境变量中,添加一个sdk的环境变量 uploading-image-95 ...
- React Native踩坑之无法启动Debug
问题 在chrome启动debug模式,连接不到地址 解决办法 在模拟器中,ctrl+m调出command,选择dev setting,然后设置debug地址为localhost:8081
- React Native踩坑之启动android模拟器失败
报错 Could not install the app on the device, read the error above for details.Make sure you have an A ...
- React Native踩坑之Unable to load script from assets
报错: Unable to load script from assets 'index.android.bundle'. Make sure your bundle is packaged corr ...
- react native 踩坑之 SectionList state更新 不执行render重新渲染页面
官方文档中指出 SectionList 本组件继承自PureComponent而非通常的Component,这意味着如果其props在浅比较中是相等的,则不会重新渲染.所以请先检查你的renderIt ...
随机推荐
- Python学习进程
1周第1天 主要是变量的学习(11月8日) 1.1 python安装(win和linux下)1.2 ipython安装及使用1.3 变量的定义1.4 变量赋值1.5 运算符(赋值.算术.关系.逻辑)1 ...
- 《----css样式---------浮动带来的影响与解决方法---------------》
浮动就是让我们的元素脱离标准文档流,目的是为了布局好看! 浮动的现象: 脱离标准文档流被叫做脱流,同时会出现字围现象. 浮动的元素会相互贴靠,而且如果父容器空间足够大,则浮动的元素会正常紧靠也就是后一 ...
- html之select标签
循环select标签 <select name="group_id"> {% for row in group_list %} <option value={{r ...
- [LeetCode] Department Highest Salary 系里最高薪水
The Employee table holds all employees. Every employee has an Id, a salary, and there is also a colu ...
- [LeetCode] Word Break 拆分词句
Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separa ...
- http 413 wcf
在网上搜到413的解决办法有多种,看具体项目找到对应的解决办法 如果是wcf返回的413,与serverRuntime无关,只要在Binding中设置最大接收值即可, <binding name ...
- Leetcode分类刷题答案&心得
Array 448.找出数组中所有消失的数 要求:整型数组取值为 1 ≤ a[i] ≤ n,n是数组大小,一些元素重复出现,找出[1,n]中没出现的数,实现时时间复杂度为O(n),并不占额外空间 思路 ...
- iOS 读取大文件时候的注意点
转: 使用NSData读取数据,采用NSData的dataWithContentsOfFile:方法.不少人反馈说如果直接使用,将会耗尽iOS的内存. 其实这个是可以改善的. NSData还有一个AP ...
- php stdclass转数组
打印输出是这样 object(stdClass)[11] //object public 'xx' => string 'xxxxxx' (length=21)可用函数处理 get_object ...
- Oracle查询时间字段并排序
select * from geimstatus_history twhere to_date(t.data_time,'YYYY-mm-dd') = to_date(sysdate,'YYYY-mm ...