0

I am building a RSS feed on a tableview. When i run the app, on my iPhone could run smoothly while in ipad, it crashed and showed "Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: 'Could not instantiate class named UIRefreshControl'"

I tried to run the app on my ipad simulator, it also could run smoothly. May I know what is the problem for that?

Thanks

Dave DeLong
  • 242,470
  • 58
  • 448
  • 498
Clarence
  • 1,951
  • 2
  • 34
  • 49
  • Your iPad is running iOS 6, right? – Dave DeLong Sep 22 '12 at 16:37
  • first generation ipad. On 5.1.1, – Clarence Sep 22 '12 at 16:40
  • Just found this related question and answer: http://stackoverflow.com/questions/13027250/subclassing-uirefreshcontrol-but-still-supporting-ios-5-1 Not sure how to try it, since I am not intentionally calling UIRefreshControl, but it may provide help for others with the same question. – Sid Wyckoff Dec 11 '12 at 03:56

2 Answers2

5

UIRefreshControl only exists on iOS 6. So if your iPad is running 5.1.1, you won't be able to use UIRefreshControl, because UIRefreshControl did not exist in iOS 5.1.1. So when the nib decoding happens, the decoder finds "UIRefreshControl", it doesn't know what to do with it, and it crashes.

Dave DeLong
  • 242,470
  • 58
  • 448
  • 498
  • There must be something we can change in the environment or the compiler or the code that will avoid this Error. App developers still need to support the several hundred thousand iPad-1 customers out there. – Sid Wyckoff Dec 11 '12 at 03:47
  • @SidWyckoff it's easy: `if ([UIRefreshControl class] != nil) { /* add iOS 6's pull to refresh */ } else { /* use your own pull to refresh */ }` – Dave DeLong Dec 11 '12 at 19:54
5

In your storyboard, click on the tableview and go to the Attribute Inspector. Under the section "TableView Controller" there is a selection window for "Refreshing" that can be set to disabled. When I built for my iPad-1, running iOS 5.1 I got an empty tableView instead of the error, 'Could not instantiate class named UIRefreshControl'. This was to be expected since I haven't populated the device with files to select, yet.

Brad Larson
  • 170,088
  • 45
  • 397
  • 571
Sid Wyckoff
  • 83
  • 3
  • 5