Ios 为什么不';我的手机没出现吗?
我正在学习在没有故事板的情况下编写代码,我决定在我的项目中添加侧栏。我使用了EnswitftSideMenu库,他们提供的示例使用了故事板 我试图写它没有,它显示了一个侧栏,但我有一个问题。我的侧边栏实际上是一个tableviewController,它应该有2个单元格,但当我打开侧边栏时,它不会显示我的单元格。但它会打印到日志中,并添加这些单元格。(我添加了打印方法) 如果可能的话,我如何让我的细胞可见Ios 为什么不';我的手机没出现吗?,ios,swift,uitableview,sidebar,Ios,Swift,Uitableview,Sidebar,我正在学习在没有故事板的情况下编写代码,我决定在我的项目中添加侧栏。我使用了EnswitftSideMenu库,他们提供的示例使用了故事板 我试图写它没有,它显示了一个侧栏,但我有一个问题。我的侧边栏实际上是一个tableviewController,它应该有2个单元格,但当我打开侧边栏时,它不会显示我的单元格。但它会打印到日志中,并添加这些单元格。(我添加了打印方法) 如果可能的话,我如何让我的细胞可见 import UIKit class MenuTableViewController:
import UIKit
class MenuTableViewController: UITableViewController {
var arr = [String]()
override func viewDidLoad() {
super.viewDidLoad()
tableView.contentInset = UIEdgeInsetsMake(64, 0, 0, 0)
arr.append("Lesson 1")
arr.append("Lesson 2")
// 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()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// MARK: - Table view data source
override func numberOfSectionsInTableView(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 arr.count
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
print("I am calling you")
let cell = MyTableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "reuseIdentifier")
//let cell = UITableViewCell(
cell.textLabel!.text = self.arr[indexPath.row]
print(self.arr[indexPath.row])
// Configure the cell...
return cell
}
}
import UIKit
import ENSwiftSideMenu
import Cartography
class SideNavigationViewController: ENSideMenuNavigationController {
init(){
// super.init(coder: NSCode)
super.init(menuViewController: TempViewController(), contentViewController: nil)
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func viewDidLoad() {
super.viewDidLoad()
var menu = MenuTableViewController()
menu.view.frame = CGRect(x: 0, y: 0, width: 180, height: 180)
sideMenu = ENSideMenu(sourceView: self.view, menuViewController: menu, menuPosition: ENSideMenuPosition.Left)
sideMenu!.menuWidth = 180
view.bringSubviewToFront(navigationBar)
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
是否确定这是正确的重用标识符?是否设置了委托?在将数据附加到
arr
后尝试重新加载tableview是否确定这是正确的重用标识符?是否设置了委托?在将数据附加到arr
后尝试重新加载tableview