Monday, November 11, 2019

Avoid Wrong Height UITableView When Reload and Add New Row


I have a problem where I can't find the solution on the internet like google, stackoverflow and blogs. So I need to trick this so that It work like I want. It's like the bug from iOS because what's supposed to be i'm doing it's the correct way. And the error seems weird because it's only sometimes happened.
I try to find it by way and it takes long time. And finally I got the solution but I think it's not final solution but I hope iOS will fix the issue soon.

So the error it's when you first time entering UITableview.  If you dynamic height like instagram did, you will sometimes get wrong height. But if it's not you are saved. I don't know if this problem only happened to me or not but after a few years expierence. I think this bug happened not only me.

My solution is not the best but I think it's really good to hide the pain because of this annoying bug haha. What I did is to refresh three times refresh when first reload UITableview. So if you have opened the UITableview before don't need to recall it again. Because it will make the memory bad.

Tuesday, November 5, 2019

Add Loading ActivityIndicator in AVPlayer Video iOS Swift 5



This week, I want to show loading after I have a video player that uses AVPlayer library. If you're curious like me. Stay tuned in this blog or if you're in hurry just scrolling on bottom. I must've given the source code. If you're an expert it must be easy to follow.

So if you don't use playback controller library AVPlayerViewController. I mean maybe you use AVPlayer Layer. It's basically it doesn't have playback controls. It's good to use loading Activity Indicator so the user will have a good expierence to operate our app.

So basically the AVplayer itself has a loading indicator beside play/pause button as you can see on above image. But it's not enough for me because it's too little, I need something on center like I do in UIImageview or loading something like loading API.

And the problem with AVPlayer, it doesn't have delegation to perform loading action so we need to use observer to do it. And don't forget to add the ActivityIndicator itself. Define it on public class but it doesn't matter if it is in method class.