2

i'm working on an app that display a viewController when is rotated to the left and then when it's rotated to the right, it displays another view controller. my segue's style is modal and i'm using the cross dissolve transition. the problem is when i rotate left then quickly rotate to the right, the console sends me this warning:

Warning: Attempt to present <SSGraphRightViewController: 0x81159b0> on <UINavigationController: 0x82439a0> while a presentation is in progress!

is there a way to avoid this warning? maybe accelerating the time of transition timing?

HusseinB
  • 1,321
  • 1
  • 17
  • 41

1 Answers1

2

You cannot present a view controller from a view controller that is already being presented, the console is right about that so either use a different style of segue or handle it rightly.

Hope this helps : What is the difference between Modal and Push segue in Storyboards?

I had the same problem when I was trying to present a UIViewController when another UIViewController was being presented, so all I had to do was to dismiss the existing UIViewController and then present the new one. In your case it is because of the fast transition that happens during presenting a UIViewController so first dismiss the existing one and then present a new one. It should goes something like this

- (void)dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion

In the (void) completion block put your code to present the new VC, like this:

[yourVC dismissViewControllerAnimated:YES completion:^{ 
//present your new VC here.
}];

Hope it helps!!.

Satheesh
  • 10,998
  • 6
  • 50
  • 93
  • mmm..ok btw is there any way possible to let my console view the debugging of an app while it is being run on a device and not the simulator? – HusseinB Apr 06 '13 at 12:44
  • 1
    If you are using a developer profile well and good you can directly debug as you do with the simulator. If you don't or you have distribution profile only do this: Go to organizer in xcode or just press cmd+shift+2 your organizer shows up, go to 'devices' tab and select your device (on left side). Under your device you would see 'console' where you can see all your console logs. – Satheesh Apr 06 '13 at 12:47
  • sorry posted the first comment before i see your edit of your post.. i'll try that now thanks! – HusseinB Apr 06 '13 at 12:50
  • thanks it works! i got one more question, how can i manually rotate a view controller like from landscapeLeft to LandscapeRight ? – HusseinB Apr 06 '13 at 13:59
  • or if not applicable how to rotate a UIView – HusseinB Apr 06 '13 at 14:06
  • 1
    You cannot manually rotate a view controller and that is not advised. – Satheesh Apr 06 '13 at 14:11
  • 1
    How ever you can rotate a view my changing its frame with animation by using UIViewAnimation block. – Satheesh Apr 06 '13 at 14:13
  • how can i do that? ca you please forward me to any good up to the point posts? Thank you so much for posting. – HusseinB Apr 06 '13 at 14:34
  • 1
    Do it like this [UIView animateWithDuration:0.5 delay:0.0 options:UIViewAnimationCurveLinear animations:^{ //change views frame here and it happens in the animated fashion that you specify in options } completion:^(BOOL finished){ } ]; Don forget initially set the frame of view to something else and then try this piece of code. – Satheesh Apr 06 '13 at 14:37
  • 2
    This is good http://www.raywenderlich.com/2454/how-to-use-uiview-animation-tutorial and please don't thank me, we are all here to learn and do great stuff. – Satheesh Apr 06 '13 at 14:38