小编All*_*aga的帖子

在UIPageViewController中删除循环AVPlayer Observer

嗨,大家好我有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中的通知但是不起作用.

你能帮助我吗?

谢谢

mobile xcode ios swift

2
推荐指数
1
解决办法
854
查看次数

使用 JXL 和 UTF-8 编码读取文件

我需要使用带有 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)

但仍然不起作用:

这是我的输出:

你能帮助我吗?

输出在这里

java encoding utf-8 jxl

1
推荐指数
1
解决办法
2120
查看次数

当视频处于循环中时,AVPlayer保留在内存中

我需要把一个玩家放在循环中,但为什么当我添加

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时,我的内存都会增加

没有这个代码,它就会被删除.

我不知道自己要做什么

你能帮我吗?

xcode ios swift swift3

0
推荐指数
1
解决办法
776
查看次数

标签 统计

ios ×2

swift ×2

xcode ×2

encoding ×1

java ×1

jxl ×1

mobile ×1

swift3 ×1

utf-8 ×1