【发布时间】:2016-03-15 17:51:58
【问题描述】:
所以,我遇到了麻烦 - 无法重新加载 TableView 的数据,在命令行中我看到了好的数据 - 当我单击按钮时 idMeet 已更改,但在模拟器中单击按钮后我看不到刷新表视图,并且idMeet 已更改,我的查询也已更改。我知道我必须使用tableView.reloadData(),但不明白在哪里写才能正确工作?
var x = true;
@IBOutlet weak var myButton: UIButton!
@IBOutlet var tbRouteData: UITableView!
@IBAction func act(sender: UIButton) {
x = !x
getInfo()
}
override func viewDidLoad() {
super.viewDidLoad()
}
override func viewWillAppear(animated: Bool) {
self.getTmp()
}
func getInfo() -> NSMutableArray {
sharedInstance.database!.open()
var idMeet: Int
if x {
idMeet = 1
} else {
idMeet = 2
}
print(idroute)
let selectInfo: FMResultSet! = sharedInstance.database!.executeQuery("SELECT * FROM t1 AS one JOIN t2 AS two ON (one.id = two.id AND two.line_id = ?) ORDER BY two.position ASC", withArgumentsInArray: [idMeet])
...
return tmp
}
func getTmp(){
infoTmp = NSMutableArray()
infoTmp = getInfo()
}
// MARK: - Table view data source
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return infoTmp.count
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! PrivateCell
let my:Info = infoTmp.objectAtIndex(indexPath.row) as! Info
cell.listOfStop.text = my.Name.uppercaseString
return cell
}
【问题讨论】:
-
您的代码中没有重新加载
-
我问必须在哪里重新加载
标签: ios swift uitableview reloaddata