1

I want to add a UIViewController on my current UIView on a button click event. But I am not able to set the frame. How can I set the y-axis of view. I also checked out iPhone: How to set UIViewController frame? but I can't solve it.

   GalleryViewController *objgallery = [[GalleryViewController 
   alloc]initWithNibName:@"GalleryViewController" bundle:[NSBundle mainBundle]];

    objgallery.view.frame = CGRectMake(0, 88, 320, 372);
    [self presentModalViewController:objgallery animated:YES];
Community
  • 1
  • 1
Minkle Garg
  • 723
  • 3
  • 9
  • 35

1 Answers1

1

If you are trying to present a modal view that is smaller than the screen, I fear that this is not the way presentModalViewController works. It will always try and enforce its own animation/geometry.

The only way you have to go that I can think of, is creating your own (non-modal) view and then animate it to the position you like. Something along the lines of:

[self.view addSubview: objgallery.view];
[objgallery.view setFrame:CGRectMake(0, 480, 320, 372)];    
[UIView animateWithDuration:0.5 
                 animations:^{
                     [objgallery.view setFrame:CGRectMake(0, 88, 320, 372)];
                 }
                 completion:^(BOOL finished){
                 }];
sergio
  • 68,819
  • 11
  • 102
  • 123