【问题标题】:YouTube-Player-iOS-Helper can't use YTPlayerView classYouTube-Player-iOS-Helper 无法使用 YTPlayerView 类
【发布时间】:2015-08-07 12:36:33
【问题描述】:

我正在尝试实现 youtube-ios-player-helper,可在此处找到:https://github.com/youtube/youtube-ios-player-helper

我做了什么: 编辑了我的 podfile,pod 更新,一切都很好,没有任何错误,Alamofire - 它也是通过 cocoapods 添加的,仍在工作

我可以在我的工作区中看到 Pod,我什至可以在 Storyboard 中为我的 UIView 选择 YTPlayerView 作为 Class

但是在添加 IBOutlet 时,它不再识别 YTPlayerView 类了吗?!

如果没有正确添加 Pod,难道连故事板都不能选择吗?

我还尝试了“手动”方法,结果稍微好一点,因为它可以让我定义播放器,但不会让我通过 Bridging-Header 导入 YTPlayerView

【问题讨论】:

    标签: ios swift youtube youtube-api ytplayerview


    【解决方案1】:

    YTPlayerView 位于需要导入的单独 Pods 模块中。

    我的播客文件:

    platform :ios, '8.3'
    
    target 'MyApp' do
        use_frameworks!
        pod 'youtube-ios-player-helper'
    end
    

    你的 Swift 文件:

    import UIKit
    import youtube_ios_player_helper // You're missing this line
    
    class MyView: UIView { // Some class
    
        @IBOutlet var playerView: YTPlayerView!
    
        // ...
    
    }
    

    如果import youtube_ios_player_helper 不适合您,您可以将#import "YTPlayerView.h" 添加到您的桥接头中,如Fayza Nawaz's answer 中所述。

    【讨论】:

    • 你,救世主!
    【解决方案2】:

    我遇到了这个问题并通过添加来解决它 “#import YTPlayerView.h” 在我的项目中桥接头文件。要了解桥接头,请查看此链接:adding bridging header in swift ios。希望对你有帮助。

    【讨论】:

      猜你喜欢
      • 2015-05-31
      • 2017-08-15
      • 2016-03-23
      • 2016-04-26
      • 2015-09-16
      • 2016-10-29
      • 2015-09-09
      • 2017-01-31
      • 2020-01-12
      相关资源
      最近更新 更多