Post

Replies

Boosts

Views

Activity

Scroll Through Videos in TableView
I am trying to make an instagram feed of only videos. Right now I am playing videos as soon as the center of the cell is visible. When I scroll even a little (staying on the same cell) it checks again if the center is visible and so the video pauses and gets reloaded. i want it to be like instagram how the video does not pause until it goes off screen. I tried celldidEnddisplay however I just want that when the center of the cells goes off screen. and the next cell’s center comes on screen. func tableView( tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) { if let mycell = cell as? HomeTableViewCell { mycell.cellIndex = indexPath playvideo(cell: mycell) } } func scrollViewDidEndDecelerating( scrollView: UIScrollView) { self.player.pause() } func scrollViewDidEndDragging( scrollView: UIScrollView, willDecelerate decelerate: Bool) { if !decelerate { self.player.pause() } } func scrollViewDidScroll( scrollView: UIScrollView) { let cell = HomeTableView.visibleCells for everycell in cell { playvideo(cell: everycell) } } func playvideo(cell : UITableViewCell) { if let mycell = cell as? HomeTableViewCell { let cellPoint = mycell.center //let cellRect = HomeTableView.rectForRow(at: mycell.cellIndex!) if HomeTableView.bounds.contains(cellPoint) { //let completelyVisible = HomeTableView.bounds.contains(cellRect) //if completelyVisible { let timer = Timer.scheduledTimer(withTimeInterval: 1.3, repeats: false) { (timer) in self.player = AVPlayer(url: mycell.videoURL!) self.avpController.player = self.player self.avpController.view.frame.size.height = mycell.containerView.frame.size.height self.avpController.view.frame.size.width = mycell.containerView.frame.size.width mycell.containerView.addSubview(self.avpController.view) mycell.containerView.sendSubviewToBack(mycell.VideoImage) mycell.contentView.bringSubviewToFront(mycell.containerView) self.player.play() } } else if self.player != nil { self.player.pause() } } }
0
0
1.6k
Aug ’20
Navigation Bar Button Item not Visible is some phones
I have added a bar button item from storyboard in my rootview controller and added a segue. On a few phones (iphone 10 and 11) the button is not visible but can be clicked and segue is working perfectly (it is enabled). I have checked the color and it seems to be alright. I changed the navigation bar color to white (as it is in other places) but only this button does not show. I have used bar buttons elsewhere in my app and they are visible.
4
0
894
Oct ’20