gpt4 book ai didi

iphone - UIView 动画 block UIView 交互

转载 作者:行者123 更新时间:2023-11-28 20:44:37 24 4
gpt4 key购买 nike

我有一个名为 MainViewController 的 UIViewController。它的框架:我还有一个名为 SingleSearchView 的 UIView,它是 MainViewController 的 subview 。

然后我将这个 singleSearchView 添加到 MainViewController:

self.singleSearchView = [[SearchView alloc] initWithFrame:CGRectMake(0, -480, 320, 480)];
[self.view addSubview:singleSearchView];

当我尝试使用以下动画“切换”到 singleSearchView 时,它会阻止我与 singleSearchView 进行任何触摸交互/p>

[UIView beginAnimations:@"searchAnimation" context:nil];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:1.0f];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationTransition:UIViewAnimationTransitionNone forView:self.singleSearchView cache:YES];
[self.view setFrame:CGRectMake(0, 480, 320, 480)];
[UIView commitAnimations];

我也试过这种方式:

[UIView animateWithDuration:1.5 delay:0 
options:UIViewAnimationOptionAllowUserInteraction
animations:^{
[self.view setFrame:CGRectMake(0, 480, 320, 480)];
}
completion:nil];

谢谢

最佳答案

从这里answer to another question :

Turns out UIView's block animation by default blocks user interaction, and to get around it you need to pass UIViewAnimationOptionAllowUserInteraction as one of the options. Hopefully someone else will have some use of this information as well.

关于iphone - UIView 动画 block UIView 交互,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6926626/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com