UIPageControl doesn't like big numbers of pages, or how Reveal makes debugging awkward issues a piece of Cáca Milis

By: Conor 9. March 2014 20:55
So there's been a bug in the JOE.ie and Her.ie iOS apps for a while now that was originally raised back in October. You know the sort of bug that you just kinda ignore for a while and hope it'll go away or you'll magically fix it by fixing something else?


Bug report


To reproduce:

  • Launch app
  • Select any category
  • Scroll waaaaaay down until you reach articles in the 100's or 200's
  • Tap any article to open - the app will visibly stall for about 10 seconds before article opens


It's kind of edge-ish to be honest. It requires scrolling through hundreds of articles to reproduce. It's also a fucker to try and replicate and debug. Change a line of code, scroll for 5 minutes, no it's still broken. Change that line of code back, change a different one and repeat... What developer wants to do that? What developer even thinks about that, the app works grand under normal usage. But sure isn't that why we have wonderful QA people, to do weird shit with our apps? Oh the weird shit they do. Anyways...


I was working on clearing up a few other bugs in both apps this weekend so figured I'd take another look at this one. One of the issues I fixed earlier was a layout issue on 3.5 inch devices. A fairly complex layout that involved multiple nested collection views and scroll views was getting messed up on the old iPhone stubbies. You say layout issue, I say Reveal solution. Within minutes I was able to isolate the exact view and offset that was getting broken, verify in real time what value was wrong, test the correct value and then update the code base. An issue that used to take hours of searching and debugging was solved in minutes. It's no secret I am a big fan of Reveal for this exact reason. In fact I was only eulogising about it on the Apptentive Mobile Team Blog there a couple of weeks ago.


I've wandered off again, back to the bug at hand. I had a quick scan of the relevant code base and nothing really jumped out at me as the problem. It seemed to me that it was almost certainly a memory issue, but I couldn't see any real memory spikes or leaks. Then for the craic, I decided I'd take a look at the interface in Reveal before and after the stall.




Simulator before


Reveal before


Nothing really out of the ordinary here, lots of custom UITableViewCells as I would have expected. Grand.


Tap an article, long pause... ... ... ...




Simulator 1


Reveal 1


Looked OK-ish at first glance, but then I decided to take a deeper look at some of the collapsed and hidden views... like that hidden UIPageControl.


Reveal 2


Woah there horsey, what the hell are all those UIViews sitting in there? Let's unhide the UIPageControl to see what that tells us.


Reveal 3


Simulator after


That's definitely not intended behaviour! So back to the code base to see what's generating all those pages.


	if (self.tableData.count > 1) {
		self.pageControl.numberOfPages = self.tableData.count;
		self.pageControl.hidden = (self.tableData.count > 10);
		self.pageLabel.hidden = (self.tableData.count <= 10);
	else {
		self.pageBar.hidden = TRUE;
Aha! self.pageControl.numberOfPages = self.tableData.count; We were being smart about when to display the UIPageControl, but not so smart about loading up it's pages! Seems so obvious when you know what you're looking for :)


Changing the code to the following fixes the issue completely, no more stalling, not even for a split second:
	if (self.tableData.count > 1) {
		if (self.tableData.count > 10) {
			self.pageControl.hidden = TRUE;
			self.pageLabel.hidden = FALSE;
		else {
			self.pageControl.hidden = FALSE;
			self.pageLabel.hidden = TRUE;
			self.pageControl.numberOfPages = self.tableData.count;
	else {
		self.pageBar.hidden = TRUE;


So there you have it. What have we learned?


  • UIPageControl doesn't like big numbers of pages, even when it isn't getting rendered to the screen
  • Even @conorwinders makes stupid little mistakes that can have enormous consequences when uncovered
  • QA people find crazy stuff that no developer is ever going to spot by themselves
  • Reveal app is the dog's bollox
  • Kristen Stewart went topless in an advert for Balenciaga Perfume
TweetMe created by sexyselect.net/blog


blog comments powered by Disqus