【发布时间】:2022-01-23 00:31:16
【问题描述】:
我不确定我的应用发生了什么变化。最近由于某种原因,当我尝试开发它时,我的应用程序上的导航栏开始消失,然后当我向下滚动时又重新出现。这是演示此操作的屏幕截图。
是什么让我的导航栏消失了?
应用打开到左侧的屏幕截图并向下滚动以显示右侧的屏幕截图。
这是一个全新的导航控制器,我在 Storyboard 上设置并在初始视图控制器中设置。新控制器的实际swift代码如下。
import UIKit
class NewsViewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Uncomment the following line to preserve selection between presentations
// self.clearsSelectionOnViewWillAppear = false
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem
}
// MARK: - Table view data source
override func numberOfSections(in tableView: UITableView) -> Int {
// #warning Incomplete implementation, return the number of sections
return 1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows
return 50
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
// let cell = tableView.dequeueReusableCell(withIdentifier: "reuseIdentifier", for: indexPath)
let cell = UITableViewCell()
// Configure the cell...
cell.textLabel?.text = "Item \(indexPath.row)"
return cell
}
}
我在应用程序委托中有以下代码
UINavigationBar.appearance().tintColor = UIColor.primaryColor();
UINavigationBar.appearance().barTintColor = UIColor.primaryColor();
UINavigationBar.appearance().isOpaque = true;
UINavigationBar.appearance().titleTextAttributes = convertToOptionalNSAttributedStringKeyDictionary([
NSAttributedString.Key.foregroundColor.rawValue: UIColor.white
])
UITabBar.appearance().barTintColor = UIColor.primaryColor();
UITabBar.appearance().isOpaque = false;
UITabBar.appearance().tintColor = UIColor.white;
UIRefreshControl.appearance().tintColor = UIColor.white;
【问题讨论】:
标签: ios swift xcode uinavigationcontroller storyboard