-1

I have an app in AppStore (iPhone-only, iOS3.1+ compatible, 2011 Xcode 3 compile) that has been working amazingly fine for three years untouched. Recently however it started "freezing" on iOS8 under certain conditions. That happens in couple of places, both when UIActionSheet is to be shown. Nothing pops on screen, the app does not crash but instead stays irresponsive to any taps; nothing in system console. The only way "out" after that happens is to kill the app manually from the task switcher and start it again.

I believe the reason is the way i show the UIActionSheet, which was as simple as these 3 lines, from a UIViewController method:

UIActionSheet* actSheet = [[UIActionSheet alloc] initWithTitle:@"Could not connect to [...]" delegate:nil cancelButtonTitle:@"OK" destructiveButtonTitle:nil otherButtonTitles:nil]; 
[actSheet showInView:self.view.window]; 
[actSheet autorelease]; 

I think the reason is the use of self.view.window, which is UIWindow (which inherits UIView, naturally) - and that just using self.view should solve the issue (i read here https://stackoverflow.com/a/26171717/226086 that showInView: now only works with UIView with UIViewController attached). Why did i use self.view.window in the first place - probably i read about this issue with cancel button alignment.

However, i am unable to reproduce the problem when compiling my app in Xcode 6 - and Xcode 3 cannot debug iOS8. And my conundrum is how do i exorcise a bug i cannot reproduce to verify.

Do you have insight on the changed behavior of UIActionSheet, what is causing the hanging in iOS8?

PS. Please don't tell me "UIActionSheet is deprecated in iOS8, use UIAlertController instead". That is an incorrect answer: "deprecated" does not mean UIActionSheet does not work in iOS8 no more - it is just discouraged for new code and may be dropped in next versions. But i want to keep compatibility with iOS5+ (my reasoning akin to this) so i rather fix the use of it - which i mention above seems fishy with showInView:self.view.window.

Community
  • 1
  • 1
Nas Banov
  • 28,347
  • 6
  • 48
  • 67
  • In which UIViewController method are these 3 lines called? – gagarwal Feb 17 '15 at 00:18
  • Question, it's on iPad, both or iPhone only ? – gwdp Feb 17 '15 at 19:17
  • @gwdp: iPhone-only - thanks, updated above. – Nas Banov Feb 17 '15 at 19:31
  • @gagarwal, those are called in methods of my UIViewController that is on screen/has the focus. It's just a navigation bar on top with the view underneath, no tabs. In one case the calls are in `textFieldShouldReturn`, in another (another two) - when button is clicked (touch-up-inside event handler) – Nas Banov Feb 17 '15 at 19:48
  • @matt - turn comment into answer, so can get the bounty if no better explanation comes along? – Nas Banov Feb 21 '15 at 00:27

2 Answers2

1

This is a long shot, but there is an issue in iOS8 related to rotation not working when the following line is left in your app delegate didFinishLaunchingWithOptions: method. The line is a hangover from pre iOS8 xcode generation and relates to the window for the application. Only affects iOS8. Previous versions all work fine.

The line is:

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

This is nolonger needed and should be commented out. Given you are using self.view.window perhaps there is some side effect with UIActionSheet as well.

As I say, a long shot but seems a coincidence that your having an issue in iOS8 only related to using a window view.

Rory McKinnel
  • 7,936
  • 2
  • 17
  • 28
0

I dont think you should have an issue using UIAlertController, as far as support for previouis versions of iOS are concerned you can try creating instance of UIAlertController using [[UIAlertController alloc] init] if it returns nil(which it will for older versions of iOS) you can use UIAlertSheet you are using currently.

Sumeet
  • 1,055
  • 8
  • 18
  • After re-compiling under Xcode 6, `UIActionSheet` as it was used before - works again, so no need to use another entity. It remains mystery however why it stopped working under iOS8 with the old executable. – Nas Banov Feb 24 '15 at 00:01
  • 1
    Perhaps when compiling with Xcode 6 the base SDK was updated to iOS8.x and that is why it worked fine and in the older executable the base iOS SDK was an older one. – Sumeet Feb 24 '15 at 08:02
  • @uchha - yes, i think that's what "fixed" it. But i don't understand why app compiled with older SDK stopped suddenly working with iOS8? It would seem as if iOS8 is running older apps in some kind of emulator, where the API does not quite work the same way as it used to. – Nas Banov Feb 25 '15 at 03:47