0

I have created a tableview but cannot get it to come to the front of my storyboard. I have a background image view that my tableview is sitting behind and not coming to front.

self.view?.addSubview(self.tableviwe!)
        self.view?.bringSubviewToFront(self.tableviwe!)
Paul Cezanne
  • 8,629
  • 7
  • 59
  • 90
user520300
  • 1,497
  • 5
  • 24
  • 46
  • Did you create the tableView in the Storyboard ? – Norman G Feb 24 '15 at 13:18
  • no i did it programatically @IBOutlet var tableviwe: UITableView! then in viewDidLoad self.view?.addSubview(self.tableviwe!) – user520300 Feb 24 '15 at 13:20
  • if you didn't create tableview in storyboard remove IBOutlet keyword a and let var tableviwe: UITableView! only – Zell B. Feb 24 '15 at 13:22
  • am i to change IBOutlet to let var tableviwe:UITableView! ? – user520300 Feb 24 '15 at 13:32
  • You have to change to var tableviwe:UITableView? – Zell B. Feb 24 '15 at 13:33
  • this still doesn't bring it to the front – user520300 Feb 24 '15 at 14:07
  • Did you set a frame on the tableView? maybe it doesn't have any size? – chuthan20 Feb 24 '15 at 14:12
  • self.tableviwe = UITableView(frame: CGRectMake(110, 40, 100, 320)) . If i remove the image view i have for a background image i can see that this tableview is being created but it won't come in front of the image view (which i did editor -> arrange -> send to back) – user520300 Feb 24 '15 at 14:15
  • You might want to send your imageView to the back by doing `sendSubviewToBack(imageView)' – ztan Feb 24 '15 at 20:45
  • please paste the code for the background if programmatically created, the object you add to the view first is considered at the back of the stack, read here... http://stackoverflow.com/questions/30203010/how-do-i-change-the-z-index-or-stack-order-of-uiview – DeyaEldeen Jan 24 '16 at 19:36

1 Answers1

0

Just add the tableView after the imageView.

view.addSubview(backgroundImageView)
view.addSubview(tableView)
Nebojsa Nadj
  • 621
  • 3
  • 12