Search code examples
iphoneuiviewcontrollerautoresizensscrollview

View controllers crash with auto rotation


I have a UIScrollView that contains some controllers: imageView with the background image and others,

enter image description here

and when I rotate the phone, it does not auto-resize controllers

enter image description here

I have read 2 similar questions in UIWebView auto rotation corrupts web view content (screenshots inside) Scale image to fit screen on iPhone rotation and I try to add these code to the viewDidLoad

self.view.autoresizesSubviews = YES;
self.imageView.autoresizingMask = (UIViewAutoresizingFlexibleWidth |                                  UIViewAutoresizingFlexibleHeight);

self.scrollView.autoresizingMask =(UIViewAutoresizingFlexibleWidth
                              | UIViewAutoresizingFlexibleHeight); 

the problem is also not be solved. Please help me for this crash, many thanks in advance.


Solution

  • Here You are facing two Problem in Your App.

    1)Orientation problem

    2)Crash problem whenever the orientation changes.

    1) I think your app running over the iOS6 that's why the your existing Code For Orienattion not working well. SO here is the Link qt where you can see the thread for managing the orientation in iOS6 as well as iOS5.

    first Link

    Second Link For the Same.

    2) Now for Fixing the Crash . you should debug Your code properly .you have to watch the Reason behind the Crash.if the Crash happening only whenever your device orientation getting change then you should watch the control flow as orientation changes.check which line of code making the crash.

    I wish it could help you.