I am learning to make IOS Programs using Swift and Xcode. I am reading a book as well as watching videos. I ran into a problem. I created a Table View into my view controller. I know how to specify the amount of rows and what goes into the text labels. However, I don't know how to remove the extra lines that tableview produces. I only have 4 rows but it shows the blank extra rows.
Here is my code:
import UIKit /// imports the UIKit library
class MainScreenViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
@IBOutlet weak var MainScreenTableView: UITableView!
let myMenuOptions = [ "Instructions", "Create", "Open", "Send" ]
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
self.MainScreenTableView.dataSource = self // self refers to the view controler we are in
self.MainScreenTableView.delegate = self /* dataSource means the view control provides the table with information */
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.myMenuOptions.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = UITableViewCell()
cell.textLabel!.text = myMenuOptions[indexPath.row]
return cell
}
thanks