【问题标题】:How to add custom activity indicator on AVPlayerViewController in tvOS swift如何在 tvOS swift 中的 AVPlayerViewController 上添加自定义活动指示器
【发布时间】:2016-07-21 13:23:43
【问题描述】:

我正在开发 tvOS 应用程序。我有多个网格格式的视频。我使用 AVPlayerViewController 在应用程序中播放视频。 AVPlayerViewController 显示默认活动指示器,但我的要求是添加到 AVPlayerViewController 中的自定义活动指示器。如何使用 swift 添加自定义指标。 请提出建议。

【问题讨论】:

    标签: avplayer tvos apple-tv avplayerviewcontroller


    【解决方案1】:

    首先,您需要删除一个默认活动指示器。您可以在 AVPlayerViewController 子视图中找到一个活动指示器并更改样式或隐藏它。使用以下代码(它是一个 Objective-C 代码,但你可以用 Swift 重写它):

    - (void)findActivityIndicatorInView:(UIView *)view toPerformBlock:(void(^)(UIActivityIndicatorView*))block {
    
        NSArray *subviews = [view subviews];
        for (UIView *subview in subviews) {
    
            if ([subview isKindOfClass:[UIActivityIndicatorView class]]) {
    
                block((UIActivityIndicatorView*)subview);
            }
            [self findActivityIndicatorInView:subview toPerformBlock:block];
        }
    }
    

    并添加此调用:

    [self findActivityIndicatorInView:self.playerController.view toPerformBlock:^(UIActivityIndicatorView* v) {
    
            //Your actions
    }];
    

    在您可以在AVPlayerViewController 视图前面添加自定义活动指示器之后。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-04-10
      • 2013-10-28
      • 1970-01-01
      • 2020-08-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多