PopoverViewController and orientation problem

Discussion in 'iOS Programming' started by MACloop, Jun 23, 2010.

  1. MACloop macrumors 6502

    Joined:
    May 18, 2009
    Location:
    Germany
    #1
    Hello,
    I have a popoverviewcontroller which opens up when the user push a button. I have chosen no to let this view to respond on changes in the orientation. This works fine because I do not want the content in the popoverviewcontroller to change. The problem is the modalview which opens when the user clicks on one of the table cells in the popoverviewcontroller. I have set this view to react on changes in the orientations. The problems are:
    If I flip the device when this modalview is open, the view flips along and everything is ok.
    If I open up the popover thou, and then flip the device say into landscape mode and after that open up one of the modalviews is this modalview partly placed outside the screen. I suppose the problem is the popover not responding to orientation changes... Any ideas on this issue?
    MACloop
     
  2. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #2
    You may need to respond to the rotation by hiding the modal view when the rotation begins and then showing it in the correct position after the rotation completes.
     
  3. MACloop thread starter macrumors 6502

    Joined:
    May 18, 2009
    Location:
    Germany
    #3
    Thanks for your answer! Do I have to do this in the popoverViewcontroller class or in the viewcontroller self showing the modalview?

    MACloop
     
  4. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #4
    I'm having a little trouble understanding exactly what's happening.

    If the problem is that if the device rotates while the modal is visible it ends up in the wrong place, then whatever object shows the modal needs to hide it and then show it again. This probably should be a view controller.

    If the problem is that showing the modal after rotation puts it in the wrong place, I'm not sure why that is.

    One thing I noticed yesterday while working on my own popover problems is that a view controller inside a popover doesn't get the standard rotation callbacks. Also, its interfaceOrientation property is always portrait. In order for my view controller inside a popover to respond to rotation it has to register for device rotation notifications.
     
  5. MACloop thread starter macrumors 6502

    Joined:
    May 18, 2009
    Location:
    Germany
    #5
    Well, I will try to specify the problem a bit. I have a popover table as sort of menue. When the user clicks in one of the cells, a modalview is opened to give some more information on a current chosen subject. So - these situations are possible:
    1) If I have the iPad in portrait-mode and click the button to show the popoverview and then click on one of the cells in the table, the modal view shows perfectly.
    2) If I have the iPad in portrait-mode and change the orientation to landscape and then select one of the cells in the table two odd things appear. First- a part of the modalview is out side the sceen. Second - when closing the modalview, the device turns back to portrait mode...even if I had chosen the landscape even before the modaview was opened. In this portrait mode, if I click ontoher cell once again, the view turns to landscape mode again...?

    This is how I did so far:
    in the popoverviewcontroller:
    Code:
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
        return NO;
    }
    
    in the modalviewcontroller:
    Code:
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
        return YES;
    }
    
    I have tried to dismissthe modalview when rotating the view and then show it again when the rotation is done, but that did not work...
    As I can see it the content of the popover view cannot react on rotation, because that rotates the content which is a table and that is not what I want.

    Any Ideas how to workaround this problem? Moving the modalview once the device is rotated, is not the problem. My biggest problem is how the two views/controllers have to communicate in oder to get them behave "normal"

    Thanks in advance!
    MACloop
     
  6. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #6
    I assume the modal is shown with presentModalViewController. I think this violates the way that popovers are meant to work. I don't think you should show a modal view like that from a popover. What you should do I can only guess, not knowing the details of your app. Is there another app that does something similar?

    I would try to put the info that's in the modal into the popover. Either put it in the cell that's touched or at the bottom of the table.

    I think the problems that you're seeing are because apple doesn't expect anyone to do what you're trying to do.
     
  7. MACloop thread starter macrumors 6502

    Joined:
    May 18, 2009
    Location:
    Germany
    #7
    That is a pity! I found the solution pretty interesting.... I mean there must be other apps and situations where you would like to open up a modal view by clicking into a popover.... anyway - thats alot for your feedback. It saved me alot of time trying to get it work!
    MACloop
     
  8. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #8
    Let me just say that this is all IMO.

    If you were to find another app that does this you might try to do it.

    You could conceivably use a DTS incident to find out more directly from apple.
     
  9. sapateira macrumors newbie

    Joined:
    Nov 18, 2010
    #9
    Same problem here

    I'm having the same problem.

    Autorotation goes crazy whith presentModalViewController from a Popover.

    I've been Googling this for days. It seams like we're the only crazy guys with the stupid idea of switching views from a popover.

    Have you figured out how to solve this problem?
     
  10. seepel macrumors 6502

    seepel

    Joined:
    Dec 22, 2009
    #10
    I'm in the same boat, the popover controller in splitview app is all messed up. I found similar things as you folks. My solution was to implement my own animation and simply switch views by hand. On top of all this, presenting my view in the popover completely messes up my navigationBar's tintColor to the point that I can't ever set, just null every time.
     

Share This Page