IOS:在带有动画的 ImageView 下禁用 ScrollView

标签 ios xcode uiscrollview

在我的应用程序中,我有一个“启用分页”的 ScrollView ,当我选择页面时, ImageView 以这种方式开始其动画

- (void) beginWinAnimation{
[UIView animateWithDuration:2.5
                 animations:^{successView.alpha = 1.0;}
                 completion:^(BOOL finished){ 

                 [UIView animateWithDuration:2.5
                 animations:^{successView.alpha = 0;}];
                 }];}

在此动画期间,我可以看到此 successView 下的 ScrollView ,并且可以移动 ScrollView 页面;我希望在动画过程中你不能移动 ScrollView ,但只能在动画完成时移动,这可能吗?

最佳答案

是的,这是可能的。当动画开始时设置[scrollView setScrollEnabled:NO];动画完成后将其设置回YES

所以在你的代码中,它看起来像 -

- (void) beginWinAnimation{

[scrollView setScrollEnabled:NO];

[UIView animateWithDuration:2.5
                 animations:^{
                     successView.alpha = 1.0;
                 }
                 completion:^(BOOL finished){ 
                     [UIView animateWithDuration:2.5
                         animations:^{successView.alpha = 0;}
                         completion:^(BOOL finished){ 
                             [scrollView setScrollEnabled:YES];
                         }]; 
                 }];}

看看这是否有效。

关于IOS:在带有动画的 ImageView 下禁用 ScrollView ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7874528/

相关文章:

ios - 在 MVC 中绘制模型 View 或 Controller 的 UIBezierPath 部分

ios - 注册接收远程 CloudKit 更改通知不起作用

ios - AVCaptureSession commitConfiguration() 耗时太长

ios - 在 Swift 中解析 CSV 文件并将其加载到 Core Data 中

ios - Xcode 6.3 更新导致 ide 卡住并需要强制退出

ios - UIScrollView 暂停 NSTimer 直到滚动完成

iphone - scrollview 不改变 contentOffset

ios - 模仿 iOS 10 上的 adjustmentContentInset?

ios - - (UITableViewCell *)tableView :(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath is not being called

ios - 隐藏事件指示器