所以当我到达我的CartViewController时,表格加载得很好但是当我将segue传回给它时,表格变空了!!我在不同控制器中的其他TableView使用相同的代码重新加载,但这个视图控制器表现得很奇怪。
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
<style>
h1{background-color:orange;color:white;}
body{background-color:lightblue}
</style>
</head>
<body>
<h1>SIGNUP</h1>
<form name="myForm" action="login" method="post">
Name: <input type="text" name="name"><br>
Last Name:<input type="text" name="lname"><br>
DOB:<input type="date" name="dob"><br>
EMAIL:<input type="text" name="email"><br>
Password<input type="password" value="password" name="password"><br>
Mobile No:<input type="text" name="mobilenumber"><br>
Expertise Level in Biodiversity:<br><input type="radio" name="epertiselevel" value="begginer">Begginer<br>
<input type="radio" name="epertiselevel" value="intermediate">Intermediate<br>
<input type="radio" name="epertiselevel" value="advanced">Advanced<br>
<input type="radio" name="epertiselevel" value="nothing">Nothing<br>
<input type="submit" value="SIGNUP">
<input type="reset" value="Reset">
</form>
</body>
</html>
答案 0 :(得分:1)
我不确定我是否正确理解您的代码然后您在Alamofire.request函数之外调用主线程。更新您的代码如下
func getMeals () {
Alamofire.request(url!, method: .post, parameters: para,encoding: URLEncoding.default, headers: headers).responseJSON { response in
// get data code
let info = Meals(meal_id: id, Logo: logoString, meal_name: name, price: price)
self.meals.append(info)
DispatchQueue.main.async{
self.tableView.reloadData()
}
}
}