有一个MenuViewController类,其中记录了表中记录的数组:
import Foundation
import UIKit
class MenuViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
@IBOutlet weak var menuTableView: UITableView!
let myTitle = ["??????", "??????????", "?????????"]
override func viewDidLoad() {
super.viewDidLoad()
menuTableView.delegate = self
menuTableView.dataSource = self
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return myTitle.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = menuTableView.dequeueReusableCell(withIdentifier: "MenuCell") as! MenuTableViewCell
cell.labelText.text = myTitle[indexPath.row]
return cell
}
}
Run Code Online (Sandbox Code Playgroud)
你需要在里面写什么才能进入信息控制器?
我不知道如何做到这一点:当我单击某个 TableView 单元格时,我会转到 pdf 文件的某些页面(startPage 是页面的开头,endPage 是页面的结尾)。打开pdf文件的类:
import UIKit
class DetailLessonsVC: UIViewController {
let pdfTitle = "Strahov_Pages"
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func openPDFAction(title: Int, sub: Int)
{
if let url = Bundle.main.url(forResource: pdfTitle, withExtension: "pdf") {
let webView = UIWebView(frame:self.view.frame)
let urlRequest = URLRequest(url: url)
webView.loadRequest(urlRequest as URLRequest)
self.view.addSubview(webView)
}
}
Run Code Online (Sandbox Code Playgroud)
}
单击 TableView …
如何翻译"12月12日"的价值,只翻译成俄文以进一步比较几个月?
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "dd-MMMM"
let stringDate = dateFormatter.string(from: NSDate() as Date)
print(stringDate)
Run Code Online (Sandbox Code Playgroud)