我正在研究混合ios native/react-native项目.
假设UIImage我的应用程序中有一个实例.我需要在我的react-native组件中显示这个图像.我这样创建RCTRootView:
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"SomeScreen"
initialProperties:someParameters
launchOptions:launchOptions];
Run Code Online (Sandbox Code Playgroud)
接下来我该怎么办?Facebook描述了如何将<Image>组件与uri 一起使用,在本地文件系统或Web中寻址图像.但我不想下载两次(我也不想在react-native中重新实现身份验证).
有没有办法将已存在UIImage的反应原生组件传递给它?
我正在试图确定,哪个特定字符UITextView已被挖掘.我试着用characterRangeAtPoint:方法.但它总是会返回零,无论UITextView我在哪里点击.我甚至编写并运行以下代码:
for (int x = 0; x<1000; x++) {
pos.x = x;
for (int y = 0; y<1000; y++) {
pos.y = y;
UITextRange * range = [textView characterRangeAtPoint:pos];
if (range!=nil) {
NSLog(@"x: %f, y: %f", pos.x, pos.y);
}
}
}
Run Code Online (Sandbox Code Playgroud)
好吧,它永远不会到达NSLog字符串.我究竟做错了什么?
我想将自己的命令添加到选择菜单中,但也保留标准的"复制","剪切"等命令.我用这个:
UIMenuItem *myItem = [[UIMenuItem alloc] initWithTitle:@"My Command" action:@selector(myCommand:)];
[[UIMenuController sharedMenuController] setMenuItems:[NSArray arrayWithObjects: myItem, nil]];
Run Code Online (Sandbox Code Playgroud)
但是这会将我的命令添加到编辑菜单中列表的最后.我希望我的命令首先出现在其中.我怎么能实现这个目标?
ios ×3
uikit ×2
core-text ×1
iphone ×1
objective-c ×1
react-native ×1
uiimage ×1
uimenuitem ×1
uiresponder ×1