문제

I have a UITableViewController and UIRefreshControl set up. The refreshControl works and reloads the tableView. The issue is that I have a UISegmentedControl above my tableView which reloads the tableView with different data, depending on which segment you clicked on. Now I only want the refreshControl to be able to work on the first segment (which is also the default) and I want to disable it for the other two UISegmentedControl elements. Here's a screenshot of the tableView: UITableView with attached UISegmentedControl

Now, I hide it simply by setting self.refreshControl = nil and this works fine. The problem is that once I've done that (by clicking on one of the other UISC elements), I can't get it back to work in the default table. I've tried simply resetting self.refreshControl = savedRefreshControl after the @"Aktuelle Rezepte" element is selected, but this doesn't work. I further tried simply disabling and hiding it using

[self.refreshControl setEnabled:NO];
[self.refreshControl setHidden:YES];

and then resetting both of these when needed, but this does not work as well. What are your thoughts? Am I completely missing something?

도움이 되었습니까?

해결책

I found the answer - it was a stupid mistake. I declared savedRefreshControl at the top of my UITableViewController but set its property to (weak, nonatomic) instead of (strong, nonatomic), that's why resetting self.refreshControl didn't work. As has been mentioned in other posts, make sure that you don't do self.refreshControl = nil while it's still refreshing, as it screws up the app and refreshing logic.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top