transitionFromView 和索引
我正在使用一个控制器(MAIN)来管理如何在其主视图中呈现另外 2 个控制器(A 和 B)视图。 在主控制器视图中,我在主视图 xib 中创建了一个按钮。 BUTTON 必须位于 A 和 B 视图之上。
所以这就是我需要的视图层次结构:
MAIN.VIEW
|------A or B view (index 0)
|------BUTTON (index 1)
这里我如何将 A 和 B 创建到 MAIN 中:
//MAIN CONTROLLER viewDidLoad
- (void)viewDidLoad {
[super viewDidLoad];
self.A = [[A alloc] init];
self.B = [[B alloc] init];
//Start from A view visible in MAIN
[self.view insertSubview:self.A.view atIndex:0];
}
在特定操作调用之后,我想插入控制器 B 视图并删除 A。 我读到有关transitionFromView的内容,我尝试以这种方式使用它:
[UIView transitionFromView:self.A.view
toView:self.B.view
duration:1.0
options:UIViewAnimationOptionTransitionFlipFromRight
completion:^(BOOL finished) {
if (finished) {
//nothing for now...
}
}];
这里的问题是,翻转动画后B视图位于BUTTON之上,并且没有完全占据我的层次结构中A的位置(A位于索引0)
我可以添加这个代码进入完成块:
[self.view sendSubviewToBack:self.B.view];
但我认为这是一个有点棘手的解决方案:P(而且这也不是一个好的解决方案,因为它似乎在动画结束时有效地出现,但图形效果很差......)
这是最好的方法确保 A 和 B 是放置在索引 0 ?
I'm working with a controller (MAIN) that manage how presents 2 other controllers (A and B) views in its main view.
In MAIN controller View i have a BUTTON created into the MAIN view xib.
BUTTON must be over A and B view.
So this's the view hierarchy structure i need :
MAIN.VIEW
|------A or B view (index 0)
|------BUTTON (index 1)
Here how i create A and B into MAIN:
//MAIN CONTROLLER viewDidLoad
- (void)viewDidLoad {
[super viewDidLoad];
self.A = [[A alloc] init];
self.B = [[B alloc] init];
//Start from A view visible in MAIN
[self.view insertSubview:self.A.view atIndex:0];
}
After a specific action call i want to insert controller B view and remove A.
I read about transitionFromView and i tried to use it this way:
[UIView transitionFromView:self.A.view
toView:self.B.view
duration:1.0
options:UIViewAnimationOptionTransitionFlipFromRight
completion:^(BOOL finished) {
if (finished) {
//nothing for now...
}
}];
The problem here is that after flip animation B view is over BUTTON and doesn't take exactly the place of A in my hierarchy (A was at index 0)
I can add this code into completion Block :
[self.view sendSubviewToBack:self.B.view];
But i think it's a little tricky solution :P (and it's not a good solution too, because it seems appear effectively at the end of the animation with a bad graphic effect...)
Which is the best way to be sure that A and B are placed at index 0 ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
可能是 SDK 中的错误。 OpenRadar 上有一个 Bug 报告 正是这种行为。
May be a bug in the SDK. There is a Bug report at OpenRadar with exactly this behaviour.