UIView
在滑出视图的其他内容时,我在滑入另一个时遇到了一个奇怪的问题。
这是代码:
- (void)moveAddStudentViewIntoSuperView
{
CGRect viewFrame1 = self.viewThatShoudlDisappear1.frame;
CGRect viewFrame2 = self.viewThatShoudlDisappear2.frame;
CGRect newFrame = self.viewControllerThatshouldAppear.view.frame;
viewFrame1.origin.x = -300;
viewFrame2.origin.x = -300;
newStudentFrame.origin.x = 0;
NSLog(@"\n 1: %@ \n 2: %@ \n 3: %@", self.viewThatShoudlDisappear1, self.viewThatShoudlDisappear2, self.viewControllerThatshouldAppear.view);
[self.viewThatShoudlDisappear1 setFrame:viewFrame1];
[self.viewThatShoudlDisappear2 setFrame:viewFrame2];
[self.viewControllerThatshouldAppear.view setFrame:newFrame];
NSLog(@"\n 1: %@ \n 2: %@ \n 3: %@", self.viewThatShoudlDisappear1, self.viewThatShoudlDisappear2, self.viewControllerThatshouldAppear.view);
}
(通常我会setFrame
在动画中做 sUIView
但这对于这个例子并不重要,因为它无论如何都不起作用)
发生的情况是应该滑入或更确切地说现在位于(0,0)
的视图出现,但其他视图没有移开。并且仍然显示在新视图下。
奇怪的是,日志输出所有视图都在正确的位置。[self.view setNeedsLayout]
调用之间setFrame
也没有改变任何东西,更有趣的是,如果我setFrame
从新视图中删除,应该消失的视图实际上会正确消失。