嗨,大家好我有UIPageViewController和通知的问题.
我有一个带有一系列页面的页面UIPageVewController,所以在这些页面中我有一个循环播放的AV播放器如下:
func loopVideo(videoPlayer:AVPlayer){
NotificationCenter.default.addObserver(forName: NSNotification.Name.AVPlayerItemDidPlayToEndTime, object: nil, queue: nil){
[weak videoPlayer] notification in
videoPlayer?.seek(to: kCMTimeZero)
videoPlayer?.play()
}
}
Run Code Online (Sandbox Code Playgroud)
问题是,当我使用滚动更改页面时,来自其他页面的通知会更改当前播放AVPlayer的视频.我在通知中放了一个打印件,我可以看到调用其他页面的通知.我不知道自己要做什么?
我尝试使用NotificationCenter.default.removeObserver(self)删除viewDidDisappear中的通知但是不起作用.
你能帮助我吗?
谢谢
我需要使用带有 UTF-8 编码的 lib JXL 读取 excel 文件。
我已经尝试使用 WorkbookSettings 如下:
WorkbookSettings ws = new WorkbookSettings();
ws.setEncoding("UTF-8");
Workbook workbook = Workbook.getWorkbook(fileInputStream,ws);
Run Code Online (Sandbox Code Playgroud)
但是没有用。
我还尝试使用如下字节将输出字符串转换为 utf-8:
Charset.forName("UTF-8").encode(myString);
String value = new String(myString.getBytes("UTF-8"));
Run Code Online (Sandbox Code Playgroud)
但仍然不起作用:
这是我的输出:
你能帮助我吗?
我需要把一个玩家放在循环中,但为什么当我添加
NotificationCenter.default.addObserver(forName:NSNotification.Name.AVPlayerItemDidPlayToEndTime,object: nil, queue:nil){
notification in
videoPlayer.seek(to: KCMTimeZero)
videoplayer.play()
}
}
Run Code Online (Sandbox Code Playgroud)
当我在viewController中给出dismiss时,我的视图留在内存中.我是如何重现视频的,每次打开ViewController时,我的内存都会增加
没有这个代码,它就会被删除.
我不知道自己要做什么
你能帮我吗?