小编aaa*_*918的帖子

通过单击 swift 中的 TableView 单元格转到 ViewController

有一个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)

你需要在里面写什么才能进入信息控制器?

xcode ios swift

5
推荐指数
1
解决办法
8094
查看次数

转到 pdf 文件的特定页面

我不知道如何做到这一点:当我单击某个 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 …

pdf arrays tableview ios swift

1
推荐指数
1
解决办法
1723
查看次数

在Swift中用俄语格式化日期

如何翻译"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)

date swift

0
推荐指数
2
解决办法
1597
查看次数

标签 统计

swift ×3

ios ×2

arrays ×1

date ×1

pdf ×1

tableview ×1

xcode ×1