私はUISplitViewControllerを持っています。だから私はマスタービュー(すなわちテーブルビュー)をそのコンテンツのサイズまで見たい(3つの要素しかないと思う)。 self.tableview.contentsizeを試しましたが、成功しませんでした。解決策を見つけるのを手伝ってください。スプリットビューコントローラの左側にあるテーブルビューのサイズを制限する方法は?
各セルの高さは44です。 これは私が書いたコードです。
class AccountTableViewController: UITableViewController {
var filterList = [String]()
var selectedIndex = -1
override func viewDidLoad() {
super.viewDidLoad()
filterList = ["All Accounts","Business Accounts","Person Accounts"]
self.tableView.contentSize = CGSize(width: 600, height: 44*3);
}
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 3
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("accountCell", forIndexPath: indexPath)
cell.textLabel?.text = filterList[indexPath.row]
return cell
}}
あなたを示してコードを投稿してくださいテーブルビューの作成と初期化。また、あなたの細胞はどれくらいの高さですか? – thephatp
@thephatp 編集した内容を確認し、問題を解決してください。 –
明確にするために、あなたのリストの3つの項目の後ろの左側のビューの行を見たくないのですか?あるいは、そのスペースを他のものに利用したいのですか? – thephatp