私が知る限り、左側のデータと詳細は右側にあることが可能です&右側。代替品はありますか?
あなたは間違っています。任意のインターフェイスをテーブルビューセルに含めることができます。これをカスタムセルにして、必要に応じてデザインします。
import UIKit
import MapKit
class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate, MKMapViewDelegate {
@IBOutlet weak var mapView: MKMapView!
@IBOutlet weak var tableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
// Now tell the system that we are going to reference our
// hand-made table cell from a xib called "MyCell"
self.tableView.register(UINib(nibName: "MyCell", bundle: nil), forCellReuseIdentifier: "MyCell")
// These next you can do here, or in IB...
self.tableView.dataSource = self
self.tableView.delegate = self
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
//MARK: - TableViewDataSource
// ANY ViewController can do this, if we register the class as conforming
// to the `UITableViewDataSource` protocol
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 3
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
// Get a reference to an instance of our very own UITableViewCell subclass,
// Which we registered in `viewDidLoad`
let c = self.tableView.dequeueReusableCell(withIdentifier: "MyCell", for: indexPath) as! MyCell
// Whatever controls/outlets we have put in our cell subclass,
// we need to populate with data now... (I just did a label)
c.cellNumber?.text = "\(indexPath.row)"
return c
}
//MARK: - TableViewDelegate
//... implement whatever funcs you need ...
//MARK: - MKMapViewDelegate
//... implement whatever funcs you need ...
}
:あなたは正しく次のコードに2つのコンセントに接続UITableView
とMKMapView
(または使用しているものは何でも)の両方を持っているViewController
をストーリーボードまたはXIBでUIViewController
と呼ばれていると仮定すると
は、あなただけの独自のカスタム 'UITableViewCell' –
を実装する必要があります' UITableViewController'だけの便利なクラスです - すべてを行う必要が置かれていますあなたのMapControllerの 'UITableView'へのアウトレットを開き、その中に' UITableViewDataSource'と 'UITableViewDelegate'ルーチンを実装します。テーブルの列に関しては、あなた自身の 'UITableViewCell'のサブクラスを実装する必要があります。 Ray Wenderlichはこれに関する一連のチュートリアルを行っています。 – Grimxn
@Grimxn私は、実装を'UITableViewController 'として、または'Delegate'& 'DataSource'と同じファイル内に見ただけです。ルーチンの実装例はありますか?それは素晴らしいだろう... – njoye