【发布时间】:2016-12-06 07:11:41
【问题描述】:
我在TableView 之上使用UINavigationBar。每当我触摸 cell 并再次回到 TableView 时,NavigationBar 就会消失。我该怎么办?
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if indexPath.section == 0{
let cell = tableView.dequeueReusableCell(withIdentifier: fa_color_arrayOfCellData[indexPath.row].cell, for: indexPath) as UITableViewCell
let (fa_ColorArgumentsContent) = fa_color_arrayOfCellData[indexPath.row].text
cell.textLabel?.text = fa_ColorArgumentsContent
cell.textLabel?.textAlignment = NSTextAlignment.right
//set the data here
return cell
}
else if indexPath.section == 1 {
let cell = tableView.dequeueReusableCell(withIdentifier: fa_system_arrayOfCellData[indexPath.row].cell, for: indexPath) as UITableViewCell
let (fa_SystemArgumentsContent) = fa_system_arrayOfCellData[indexPath.row].text
cell.textLabel?.text = fa_SystemArgumentsContent
cell.textLabel?.textAlignment = NSTextAlignment.right
//set the data here
return cell
}
else if indexPath.section == 2{
let cell = tableView.dequeueReusableCell(withIdentifier: fa_support_arrayOfCellData[indexPath.row].cell, for: indexPath) as UITableViewCell
let (fa_SupportArgumentsContent) = fa_support_arrayOfCellData[indexPath.row].text
cell.textLabel?.text = fa_SupportArgumentsContent
cell.textLabel?.textAlignment = NSTextAlignment.right
//set the data here
return cell
} else {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as UITableViewCell
let (fa_SupportArgumentsContent) = fa_color_arrayOfCellData[indexPath.row].text
cell.textLabel?.text = fa_SupportArgumentsContent
cell.textLabel?.textAlignment = NSTextAlignment.right
return cell
}
【问题讨论】:
-
您是否将视图控制器嵌入到 uinavigation 控制器中?
-
@Tj3n 是的,我愿意。
-
在你的 viewdidapper() 中写一行 self.navigationController.navigationBarHidden = NO;
-
hmm...它不应该只是消失,您是否创建 segue 以在您触摸单元格后指向视图控制器?
-
@fatemeh 你能解释一下你是不是在点击单元格时推动另一个视图控制器,当你回来时你弹出那个控制器吗?
标签: ios swift uitableview uinavigationbar