我使用的 YouTube 图标来自:https ://github.com/oblador/react-native-vector-icons
我使用的是 Ionicons 的“logo-youtube”,我希望中间的播放三角形(透明)为白色,而周围部分为红色,但是如果我添加白色背景颜色,周围将会有一个白色框图标,并将 padding 设置为 0 根本没有任何作用。如何在整个图标周围没有背景框的情况下使透明中间着色?
我正在使用react-native-camera的条形码扫描仪,目前如果我使用它并且有多个 QR 码彼此紧密重叠,我将我的相机指向一个,它会读取它上面的代码,它在显示在屏幕上,但在摄像机视图内。但是,如果我要扫描的上面没有二维码,那么它会扫描正确的二维码,因此它似乎总是扫描相机视图中的顶部二维码。
这是我的问题:有没有办法将“扫描区域”限制为与显示器上的相机视图相同的大小和区域?
<View style={styles.container}>
<Camera
style={styles.preview}
onBarCodeRead={this.onBarCodeRead}
ref={cam => this.camera = cam}
aspect={Camera.constants.Aspect.fill}>
</Camera>
<Button
style={styles.buttonStyle}
<Text>{this.state.qrcode}</Text>
</Button>
</View>
const styles = {
container: {
height: 300,
flex: 1
},
preview: {
flex: 1
},
buttonStyle: {
marginTop: 20,
marginLeft: 20,
marginRight: 20,
marginBottom: 20,
alignSelf: 'center'
}
}
Run Code Online (Sandbox Code Playgroud)
版本,如果需要:
"react-native": "0.42.3",
"react-native-camera": "0.6.0",
Run Code Online (Sandbox Code Playgroud) 有谁知道我怎么能解决这个我得到的错误?在以下代码块的第一行收到错误:
let fetchedResultsController: NSFetchedResultsController = {
let fetchRequest = NSFetchRequest<NSFetchRequestResult>(entityName: "Message")
let delegate = UIApplication.shared.delegate as! AppDelegate
let context = delegate.persistentContainer.viewContext
let frc = NSFetchedResultsController(fetchRequest: fetchRequest, managedObjectContext: context, sectionNameKeyPath: nil, cacheName: nil)
return frc
}()
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用本地存储来存储一个数字,以便即使我刷新或重新访问页面它也会保持不变,但是每当我刷新时,返回值为 0。
我知道这可能是一个我无法弄清楚的非常简单的解决方法,但我非常感谢这个初学者(可能)简单问题的答案。
如果您想知道这是针对星级评分系统的。
HTML:
<p id="r1"></p>
Run Code Online (Sandbox Code Playgroud)
jQuery:
$(document).ready(function(){
var x1;
x1 = +localStorage.getItem("x1");
$("#r1").html("Your rating: " + x1);
$("#rating1 span").click(function() {
x1 = 5 - $(this).index();
$("#r1").html("Your rating: " + x1);
});
localStorage.setItem("x1", x1);
});
Run Code Online (Sandbox Code Playgroud) 我已经构建了一个我希望能够发送电子邮件的表单,为此我尝试遵循此 YouTube 教程:https://www.youtube.com/watch ?v=_3-By9QfFa0
然而,我遇到了一个问题,当我尝试提交表单时,我的控制台网络浏览器中出现问题标题错误。我意识到这个问题可能与某处的其中一条路线有关,但我只是无法弄清楚(除非它是完全不同的东西)。
schoolForm.js
const handleSubmit = async(e) => {
e.preventDefault();
try { //I also tried using only: "/send_mail" here like I have in server.js but it didnt work
await axios.post("http://localhost:3000/send_mail", {
name
});
}
catch (error) {
console.log(error);
}
}
Run Code Online (Sandbox Code Playgroud)
服务器.js
const express = require("express");
const app = express();
require("dotenv").config();
const bodyParser = require("body-parser");
const cors = require("cors");
const nodemailer = require("nodemailer");
app.use(bodyParser.urlencoded({extended: true}));
app.use(bodyParser.json());
app.use(cors());
app.post("/send_mail", cors(), async (req, res) => {
let {text} = …Run Code Online (Sandbox Code Playgroud) 我有一个函数通过滑动tableView单元从我的firebase数据库中删除一个对象,但是我的tableView单元格还包含保存在firebase存储中的图像,我希望在删除数据时也可以从存储中删除图像从数据库中,我该如何做到这一点?
删除代码:
func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
if editingStyle == .delete {
let name = food[indexPath.row].name
let ref = Database.database().reference().child("Recipes")
ref.queryOrdered(byChild: "Name").queryEqual(toValue: name).observe(.childAdded, with: { (snapshot) in
//Removes deleted cell from firebase
snapshot.ref.removeValue(completionBlock: { (error, reference) in
if error != nil {
print("There has been an error: \(error)")
}
//Removes deleted cell from array
food.remove(at: indexPath.row)
//Removes deleted cell from tableView
tableView.deleteRows(at: [indexPath], with: .left)
})
})
}
}
Run Code Online (Sandbox Code Playgroud)
装货代码:
let parentRef = Database.database().reference().child("Recipes") …Run Code Online (Sandbox Code Playgroud) 我使用本机基本输入组件,我尝试自定义占位符字体样式,如下例所示,但它不会更改占位符.它改变了用户输入值的样式.如何更改占位符字体样式?
<Input
style={{color:"blue", fontFamily:"Arial"}}
placeholder="I am blue and Arial font"
/>
Run Code Online (Sandbox Code Playgroud)
更新
我已经尝试placeholderStyle过以下示例,但它不起作用.
<Input
placeholderStyle={{color:"blue", fontFamily:"Arial"}}
placeholder="I am blue and Arial font"
/>
Run Code Online (Sandbox Code Playgroud) 所以我试图读取下面“食谱”下的 autoID 子项的子项是我的 Firebase 数据库的图片,下面是应该检索“描述”和“名称”的值并将它们插入到变量中的方法.
我目前在运行应用程序时遇到的错误是:
Could not cast value of type '__NSCFString' (0x10ad2afb8) to 'NSDictionary' (0x10ad2bfa8).
Run Code Online (Sandbox Code Playgroud)
ref = Database.database().reference()
databaseHandle = ref?.child("Recipes").observe(.childAdded) { (snapshot) in
for snap in snapshot.children
{
let recipeSnap = snap as! DataSnapshot
let recipeID = recipeSnap.key
let dict = recipeSnap.value as! [String:AnyObject]
let recipeName = dict["Name"] as! String
let recipeDescription = dict["Description"] as! String
print("key = \(recipeID) and name = \(recipeName) and description = \(recipeDescription)")
}
}
Run Code Online (Sandbox Code Playgroud)
打印语句仅用于测试。
ios ×3
react-native ×3
swift ×3
firebase ×2
javascript ×2
reactjs ×2
android ×1
axios ×1
barcode ×1
camera ×1
css ×1
html ×1
icons ×1
jquery ×1
local ×1
native-base ×1
node.js ×1
nodemailer ×1
qr-code ×1
storage ×1
swift4 ×1
uitableview ×1