Reputation: 2625
Am trying something so trivial! Can't believe it's not working! Maybe am overlooking something! Am having a home page in my iPhone app. I want to now add a subview which will be initially out of the screen (i.e. hidden to the right i.e. its frame.origin.x will be the screen width), and then I want to animate its entry into the page with a flip-horizontal and show the subview partially (only half-screen approximately).
[self.mySubview.view setFrame:CGRectMake([[UIScreen mainScreen] bounds].size.width, 0.0, [[UIScreen mainScreen] bounds].size.width, [[UIScreen mainScreen] bounds].size.height)]; [self.view addSubview:self.mySubview.view]; NSLog(@"frame before x %f", self.mySubview.view.frame.origin.x); [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:1.0]; [self.mySubview.view setFrame:CGRectMake([[UIScreen mainScreen] bounds].size.width*(2/5), 0.0, [[UIScreen mainScreen] bounds].size.width, [[UIScreen mainScreen] bounds].size.height)]; [UIView commitAnimations]; NSLog(@"frame x %f", self.mySubview.view.frame.origin.x);
Am trying to run this on an iPad. But the subview's frame is not getting set to 768.0 initially. Also, the animation is not happening. Before and after the animation, the subview's frame.origin.x is only 0.0. Where could I have gone wrong? Please help. I tried varying the autosizing arrows in the storyboard (removing them, adding them) ... nothing seems to work!
Upvotes: 1
Views: 579
Reputation: 121
Try This
Someviewcontroller *c = initWithNibName
c.view.frame = CGRectMake(0, 0, 200, 200);
[self addSubView:c];
Upvotes: 1