I have a UISplitViewController. So I want to see my master view(i.e table view) upto the size of its content (consider it have only 3 element's).
I tried With self.tableview.contentsize but did not succeeded. Please help me finding solution.
Each cell's Height is 44 . This is the Code That I wrote.
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
}}