我试图设置导航项目的标题。
但我收到如下错误消息
有人知道这个问题吗?
这是我的代码
导入UIKit
import Parse
var show = String()
var user = String()
class FansTableVC: UITableViewController {
//Arrays to hold data received from servers
var usernameArray = [String]()
var profileImgArray = [PFFile]()
// Array showing who do we follow or who followings us
var myfansArray = [String]()
//Array showing who do we follow or who following us
var followingArray = [String]()
override func viewDidLoad() {
super.viewDidLoad()
//Title at the top
self.navigationItem.title = show
// New back button
self.navigationItem.hidesBackButton = true
let backButton = UIBarButtonItem(image: UIImage(named: "backBtn"), style: UIBarButtonItemStyle.plain, target: self, action: #selector(FansTableVC.back(_:)))
self.navigationItem.leftBarButtonItem = backButton
self.navigationItem.leftBarButtonItem?.setBackgroundVerticalPositionAdjustment(-8, for: UIBarMetrics.default)
// self.edgesForExtendedLayout=UIRectEdge.None;
// self.extendedLayoutIncludesOpaqueBars = false;
// self.automaticallyAdjustsScrollViewInsets = false
// self.tableView.contentOffset = CGPointMake(0, 44.0);
self.tableView.contentInset = UIEdgeInsetsMake(16.0, 0.0, 0.0, 0.0);
self.tableView!.rowHeight = UITableViewAutomaticDimension;
self.tableView!.estimatedRowHeight = 82.0 //needed for autolayout
//load Fans
if show == "Fans" {
loadFans()
}
//load Followings
if show == "Followings" {
loadFollowings()
}
}
//cell height
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableViewAutomaticDimension
}
此代码在Xcode 7中运行良好。它刚刚发生在Xcode 8