1

Below is my code..

TestTemp1ViewController *temp=[[TestTemp1ViewController alloc]init]; 
[self.view addSubview:temp.view];
[self presentModalViewController:temp animated:FALSE];

This codes works well in iOS 5.0 but crashes in iOS 6.0.

Crash report: [UIViewController loadViewIfRequired]-- bad excess 

I cannot understand why this isn't working in iOS 6.0. Guys, ya I know that's not the good way but what I am trying to do is presentviewcontroller with grow and shrink animation. If I do this after I present then I will get white background of view controller.

Below is my code...

-(void)animateGrowAndShrink:(ViewController *)controller1 {
    //self.view.userInteractionEnabled=NO;
    [self.view addSubview:controller1.view];
    [self presentModalViewController:self.controller animated:FALSE];
    if (dayTimeLineIsShown) {
        //shrink dayTimeLineIsShown=FALSE;
        [UIView beginAnimations:@"animationShrink" context:NULL];
        [UIView setAnimationDuration:.61f];
        controller1.view.transform=CGAffineTransformMakeScale(.01f,.01f);
    } else {
        //expand dayTimeLineIsShown=TRUE;
        controller1.view.transform=CGAffineTransformMakeScale(0.01,0.01);
        [UIView beginAnimations:@"animationExpand" context:NULL];
        [UIView setAnimationDuration:.60f];
        timeLine.view.transform=CGAffineTransformMakeScale(1, 1);
    }
    [UIView setAnimationDelegate:self];
    [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];     
    [UIView commitAnimations];
}

-(void)animationDidStop:(NSString *)animationID finished:(BOOL)finished context:(void *)context{
    self.view.userInteractionEnabled=YES;
   if ([animationID isEqualToString:@"animationExpand"]) {
        [self presentModalViewController:self.controller1 animated:FALSE];
    } else {
        self.controller.view.hidden=true;
    }
}.

Also the controller in which I am doing this is also presented modally if I remove that then it's works in ios 6. Any other idea to achieve zooming and shrinking.

Ashish Singh
  • 53
  • 11
  • well its a fundo idea came to my mind just flip the order of your 2 lines [self.view addSubview:controller1.view]; [self presentModalViewController:self.controller animated:FALSE]; present modal view controller 1st Ignore if dosent work :D n do let me know . – Vinay Chopra Jan 30 '13 at 14:20
  • Vinay, it just add white blank view.I think when we do just after that view is loaded yet... – Ashish Singh Jan 30 '13 at 14:36
  • somewhere I saw this for transparent background of viewcontroller controller1.modalPresentationStyle = UIModalPresentationCurrentContext; But doesn't working on my side... – Ashish Singh Jan 30 '13 at 14:37
  • Guys I found a solution..I was setting presentation style wrong..It should be like this.. self.modalPresentationStyle = UIModalPresentationCurrentContext; It should be one current context.So, Now no need to add the controller view before presenting it.Now presented view controller view will be drawn on transparent background so while shrinking it's view, there will be no white background behind it. – Ashish Singh Jan 30 '13 at 15:21
  • well,for d same reason i suggested that fundu idea ;) well its nice u did R&D n got the desired solution :) well have a look on this link http://stackoverflow.com/questions/12507455/a-lot-of-functions-are-deprecated-ios-6 that will help. cheers :) – Vinay Chopra Jan 30 '13 at 17:18

2 Answers2

1

-presentModalViewController and -addSubview are quite different are they're not supposed to be used together. See: When should I use the addSubview method of a view controller?

I think remove the second line or third line will eliminate the error.

Community
  • 1
  • 1
Hvordan har du det
  • 3,605
  • 2
  • 25
  • 48
0

I was setting presentation style wrong..It should be like this..

self.modalPresentationStyle = UIModalPresentationCurrentContext;

It should be on current context.So, Now presented view controller view will be drawn on transparent background and not on white background so while shrinking it's view, there will be no white background behind it.

Ashish Singh
  • 53
  • 11