PLVWebViewManager
Objective-C
@interface PLVWebViewManager : NSObject
Swift
class PLVWebViewManager : NSObject
PLVWebViewSDK 核心类,支持以下功能:
- 支持适配保利威的直播页面
- 支持浮窗展示保利威的直播页面
- 也支持作为其他h5网页的容器
-
委托监听
Declaration
Objective-C
@property (nonatomic, weak) id<PLVWebViewManagerDelegate> _Nullable delegate;
Swift
weak var delegate: PLVWebViewManagerDelegate? { get set }
-
是否要使用浮窗功能,默认为YES
Declaration
Objective-C
@property (nonatomic) BOOL allowFloatingWindow;
Swift
var allowFloatingWindow: Bool { get set }
-
webView配置Block
Declaration
Objective-C
@property (nonatomic, copy) PLVWebViewConfigBlock _Nonnull webViewConfigBlock;
Swift
var webViewConfigBlock: PLVWebViewConfigBlock { get set }
-
webView默认user-agent
Declaration
Objective-C
@property (nonatomic, copy, readonly) NSString *_Nonnull defaultUserAgent;
Swift
var defaultUserAgent: String { get }
-
当前打开网页是否支持浮窗功能 (需要在attachWebViewInParentView:调用后获取)
Declaration
Objective-C
@property (nonatomic, readonly) BOOL supportFloatingWindow;
Swift
var supportFloatingWindow: Bool { get }
-
浮窗类型(YES:系统浮窗,NO:应用内浮窗) 默认为NO
Declaration
Objective-C
@property (nonatomic, readonly) BOOL isSystemFloatingWindow;
Swift
var isSystemFloatingWindow: Bool { get }
-
应用内悬浮小窗视图,可以进行样式处理
Declaration
Objective-C
@property (nonatomic, strong, readonly) UIView *appWindowView
-
webView 管理器单例类
Declaration
Objective-C
+ (nonnull instancetype)sharedManager;
Swift
class func shared() -> Self
-
添加webView到parentView中,并打开url为webViewUrl的网页
Declaration
Objective-C
- (void)attachWebViewInParentView:(id)parentView webViewUrl:(nonnull NSString *)webViewUrl;
Swift
func attachWebView(inParentView parentView: Any!, webViewUrl: String)
-
mainWebview所在控制器页面(还原小窗时需要用到)
Note
进入页面时调用Declaration
Objective-C
- (void)setupWebViewController: (id<PLVWebViewControllerProtocol> _Nullable)webViewController;
Swift
func setupWebViewController(_ webViewController: PLVWebViewControllerProtocol?)
-
页面销毁时调用该方法回收不需要的webView
Declaration
Objective-C
- (void)webViewDealloc;
Swift
func webViewDealloc()
-
主动切换到悬浮窗
Note
当allowFloatingWindow为YES、supportFloatingWindow也为YES时才会切换Declaration
Objective-C
- (BOOL)changeToFloatingWindow;
Swift
func changeToFloatingWindow() -> Bool
-
主动恢复为非悬浮窗
Note
主动调用不触发相关回调Declaration
Objective-C
- (void)postRevertWindowToNormal;
Swift
func postRevertWindowToNormal()
-
主动关闭悬浮窗
Note
主动调用不触发相关回调Declaration
Objective-C
- (void)closeWindow;
Swift
func closeWindow()
-
设置悬浮窗大小,宽高均应为正数,如不设置或参数不规范,则使用默认值
Note
如不设置或参数不规范,主动唤出浮窗时浮窗宽度为屏幕的0.3倍,宽高比16:9,js唤出浮窗时以h5告知的宽高为准Declaration
Objective-C
- (void)setFloatingWindowSize:(CGSize)size;
Swift
func setFloatingWindowSize(_ size: CGSize)
Parameters
size
悬浮窗的宽高,
-
设置悬浮窗位置,如不设置则使用默认值
Declaration
Objective-C
- (void)setFloatingWindowLocation:(CGPoint)point;
Swift
func setFloatingWindowLocation(_ point: CGPoint)
Parameters
point
悬浮窗右下角距离屏幕右下角的相对位置,默认为(-10, -100), 表示悬浮窗右边沿距离屏幕右边沿10pt,下边沿距离屏幕下边沿100pt
-
设置浮窗类型 默认为NO
Declaration
Objective-C
- (void)setFloatingWindowType:(BOOL)isSystemFloatingWindow;
Swift
func setFloatingWindowType(_ isSystemFloatingWindow: Bool)
Parameters
isSystemFloatingWindow
YES:系统浮窗,NO:应用内浮窗