0

I have a view, and a button in this view. When I press this button I need open other view as a frame. Searching I found this post: iOS -- how do you control the size of a modal view controller?

I modify this and I doing this in a IBAction connected to a button:

View2Controller *screen = [[View2Controller alloc] initWithNibName:nil bundle:nil]; //Line add
UIView *myHalfView = [[UIView alloc] initWithFrame:screen.view.frame]; //Line modified by me
[self.view addSubview:myHalfView];
CGRect offScreenFrame = myHalfView.bounds;
offScreenFrame.origin = CGPointMake(0.0, CGRectGetMaxY(self.view.frame));

[UIView beginAnimations:nil context:nil];
myHalfView.center = CGPointMake(myHalfView.center.x, myHalfView.center.y - myHalfView.bounds.size.height);
[UIView commitAnimations];
[myHalfView release];

But when I press that button nothing happens. I've verified the code runs in debug it step by step. Thanks.

Community
  • 1
  • 1
JSanchez
  • 35
  • 6

3 Answers3

1

Take a peak at this it's golden... read the comments in there as well.

http://humblecoder.blogspot.com/2009/04/iphone-tutorial-navigation-controller.html

Mytheral
  • 3,929
  • 7
  • 34
  • 57
0

Your View2Controller is initialized without a nibname?

I typically have a xib I built in Interface Builder in and do the following (have the view in the xib be whatever size you want by default if it doesn't change):

MyViewController* controller = [[MyViewController alloc]initWithNibName:@"MyViewController" bundle:nil];
[navigationController.view addSubview:controller.view];
//manipulate controller.view here
[controller release];
Tyler Zale
  • 634
  • 1
  • 7
  • 23
0

Thanks all for the replies. Finally I do this and works:

First in my IBAction:

View2Controller* modalViewController = [[[View2Controller alloc] initWithNibName:@"View2Controller" bundle:nil] autorelease];
[self.view addSubview:modalViewController.view];

Then in View2Controller.m in viewDidLoad:

[self.view setBackgroundColor:[UIColor clearColor]];

[UIView beginAnimations:nil context:nil];
[self.view setFrame:CGRectMake(0, 1024, 128, 600)];
[UIView setAnimationDuration:0.75f];
[self.view setFrame:CGRectMake(0, 404, 128, 600)];
[UIView commitAnimations];
JSanchez
  • 35
  • 6