Tuesday, 15 July 2014

ios - UIView Components Not Moving With View -


I have created a UIView in a storyboard. See for more information. My issue is when the user "logs in" then I present a new view which is brought from the left side of the screen and the main view is closed on the left side, such as push navigation, but all programmatically

So I decided to animate this "navigation" using the following code. See = [[UIView alloc] initWithFrame: CGRectMake (0, 0, 320, 480)]; View.backgroundColor = [UIColor whiteColor]; // Add content to view [add addview view: label]; View.frame = CGRectMake (320, 0, 0, 480); See.clipsbybound = yes; [Self.view addSubview: view]; // show view [UIView Animative Withdrawan: .5 Animation: ^ {self.view.frame = CGRectMake (0,0,0,480); // Move the self view from the left view. Frame = CGRactam (0, 0, 320, 480); // move the new view into place}];

My view is being displayed successfully but the current view, self.view is not going from the left side of the screen as I want. It moves, but it does not take its components with it ... when I // view.frame - CGRectMake (0,0,320,480); Comment inside the animation, so I do not show the new scene I get in the simulator on login.

The white background of the scene leaves the screen but does not leave the components. This causes a problem because when I put two together, it does not seem that "new view" is replacing the old scene with the navigation push controller, but instead it has to be slide. There is a way to move these components with self.view when I take it to the screen

Thanks for the help!

I'm not sure that you can move self.view . Even if this is possible, this is not a good idea ...

Still your code

  self.view.frame = CGRectMake (0, 0,0480);   

The view slides does not show this view in the zero-width rectangle, which states that its subview is still in the scale view Also why are default subvues combine in the top-left corner of their supervision, and since the top-left of self.view have not gone (still (0, 0)), they They remain the same. The correct way to slide a view from the screen is:

  self.view.frame = CGRectMake (-320,0,320,480); // width & amp; The height is definitely unchanged   

However, this will not work, because you have a subview of view self. View is created ... which means that this line:

  view.frame = CGRectMake (0, 0, 320, 480);   

view.frame related to self.view that the screen is now off! So both of them have gone, another good reason is that you should not play with self.view.frame .

IMHO, you should make a view v1 as the main view, and v2 log in such a scene that will appear. Make both sublayes of self.view , hide v1 behind v1 and when the user logs in, then slide v1 as shown above the screen. Or perhaps by putting v1 on the right side of v2, and sliding both of them (so v1 will exit because sliding in v2, similar to navigation controller).

No comments:

Post a Comment