Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableViewController Refresh control is nil

I have a UITableViewController in my project and set the "Refreshing" to enabled in Storyboard. However, the outlet of that is nil.

Using it like this

self.refreshControl

Even if I make I custom outlet from the storyboard to the viewcontrolelr it is nil. It works for other table views in my project, just not for this.

Is there anything quick I probably have missed?

like image 771
user2529173 Avatar asked May 24 '16 18:05

user2529173


2 Answers

Select your TableViewController in the storyboard and enable refreshing. As depicted in the attached image. I hope this would help.

Storyboard attribute inspector image

like image 161
Tul Avatar answered Sep 21 '22 17:09

Tul


you created via storyboard fine. try once remove from storyboard and add it again.

then initiate that in your viewDidLoad Method

like self.refreshControl = UIRefreshControl()

or you can create programatically it will be easy.

create one global Property

var refreshControl : UIRefreshControl?

in viewDidLoad Add

self.refreshControl = UIRefreshControl()

if let refreshControl = self.refreshControl{
   refreshControl.addTarget(self, action: #selector(viewCtrl.refresh(_:)), forControlEvents: UIControlEvents.ValueChanged)
   self.Tableview.addSubview(refreshControl)
}

This will fix your problem.

like image 25
karthik Avatar answered Sep 23 '22 17:09

karthik