最後のセル/行(mapView)が空のスペースを埋めるようにします。 uitableviewの最後の行を空白スペースに埋め込む方法
マイtableviewcontrollerコード
class CustomTableViewController: UITableViewController {
let fakeArray = ["Row1","Row2","Row3"] // Array can contains more items
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return fakeArray.count+1
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
if(indexPath.row != fakeArray.count){
let cellIdentifier = "TestTableViewCell"
let cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier, forIndexPath: indexPath) as! TestTableViewCell
cell.rowName.text = fakeArray[indexPath.row]
return cell
}else{
let cellIdentifier = "MapTableViewCell"
let cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier, forIndexPath: indexPath) as! MapTableViewCell
return cell
}
}
override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
if(indexPath.row != fakeArray.count){
return 44
}else{
return 80
}
}
}
は、時々私は、マップ前にディスプレイに複数の行を持つことになります。したがって、下の空白のスペースは変わる可能性があります。コースの空きスペースもiPhoneの画面サイズによって変わります。
最後の行の行の高さを増やすことができます。 –
私は、テーブルビューのフッタービューにマップを配置します。 – dasdom
地図の前にたくさんの行を表示して、地図が表示されないことはありますか?それでは? –