iPhone SDK - 动画效果子视图 [英] Iphone SDK - Animating Subview

查看:108
本文介绍了iPhone SDK - 动画效果子视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个观点,即有一个UIWebView,和OptionsPane(自定义UIViewController中使用自定义视图)。

我要当显示的视图,对于选项窗格(位于主视图的顶部)翻转到位。我现在用的是code和我得到一个奇怪的结果。

该视图显示在第一时间,选项面板似乎已是可见的。当我打回我的navController,再次拉起视图,动画完美的作品。

任何人都可以提供一些线索关于这一主题?

   - (无效)viewDidLoad中{
    [超级viewDidLoad中];
    optionsPane = [[OptionsPaneController页头] initWithNibName:@OptionsPane捆绑:无];
} - (无效)viewWillAppear中:(BOOL)动画{    [optionsPane.view removeFromSuperview]
    [个体经营checkOptionsVisible]
} - (无效){checkOptionsVisible
    [UIView的beginAnimations:无背景:无];
    [UIView的setAnimationDuration:0.5];
    [UIView的setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:[​​optionsPane观点】缓存:YES];
    [自拍] addSubview:[​​optionsPane视图]];
    [theWebView SETFRAME:CGRectMake(0,87,320,230)];
    [optionsPane观点】SETFRAME:CGRectMake(0,0,320,87)];
    [UIView的commitAnimations];
}


解决方案

如果我理解你解释什么,我有一天有一个非常类似的问题。

什么发生在第一次加载的是viewDidLoad中触发第一。加载笔尖文件比它需要的viewWillAppear中火本身更多的时间。

我们现在越来越是一个笔尖加载后viewWillApper已经退休。

在以后的任何负载时,viewDidLoad中会不火,让viewWillAppear中做它的忠实翻转的工作。

该怎么办?

首先,尝试改变你的code用viewDidAppear。这应该帮助,但你必须看到,如果它看起来不错。

另一种选择(丑,我知道)是对viewDidLoad中来checkOptionsVisible打电话了。

如果这种帮助非,我会考虑一个定时器作为黑客 - 如果要求允许它

我希望让你更接近解决问题。

I have a View that has a UIWebView, and an OptionsPane (Custom UIViewController with Custom view).

I want when the view is shown, for the options pane (located on the top of the main view) to FLIP into place. I am using the code, and I am getting a strange result.

The FIRST time the view is shown, the options pane seems to already be visible... When I hit BACK on my navController, and pull up the View again, the animation works perfectly.

Can anyone shed some light on this topic?

- (void)viewDidLoad {
    [super viewDidLoad];
    optionsPane=[[OptionsPaneController alloc] initWithNibName:@"OptionsPane" bundle:nil];
}

- (void)viewWillAppear:(BOOL)animated {

    [optionsPane.view removeFromSuperview];
    [self checkOptionsVisible];
}

-(void)checkOptionsVisible{
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.5]; 
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:[optionsPane view] cache:YES];
    [[self view] addSubview:[optionsPane view]];
    [theWebView setFrame:CGRectMake(0,87,320,230)];
    [[optionsPane view] setFrame:CGRectMake(0,0,320,87)];
    [UIView commitAnimations];      
}

解决方案

If I understand what your explaining, I had a very similar problem the other day.

What happening on the first load is that viewDidLoad fires first. loading the nib file takes a bit more time than it takes for the viewWillAppear to fire itself.

What we're getting is a nib loads after the viewWillApper already retired.

On any load after that, the viewDidLoad will not fire, letting the viewWillAppear to do its loyal flipping job.

What to do?
First, try to change your code to use "viewDidAppear". That should help, but you have to see if it looks good.

Another option (ugly one, I know) is to have a call to checkOptionsVisible on the viewDidLoad too.
If non of that help, I would consider a timer as a hack - if the requirements allow it.

I hope that make you closer to solve the problem.

这篇关于iPhone SDK - 动画效果子视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆