Tuesday, October 29, 2019

How to get thumbnail from video URL in Swift 5

If you want to show video in your app and you want to show thumbnail. The easy way is to get image url from server API. But there is more easy way you just need to get url video and get image url. I have searched on the internet but what I found my app becomes lag. I use UITableview to show the video thumbnail url.

Maybe you wonder why I use image thumbnail. I can use video player from iOS and thumbnail video will be shown. But what if you use many thumbnail in UITableview, it will be heavy in the device. It's bad design too.

It will be good for you, if you can combine this extension image with SDWebImage. Because the image will be in cache and you don't need to reload image again. But you still need the internet to load the video url. Because it's online from the internet.

This is swift code and about objective-c code, it's better you search on the internet. I know it's really painful to change it to swift if you have developed big app. So you can convert swift to objective-c but it's not sure there will be a match library between swift and objective-c.

Tuesday, October 22, 2019

Create Rectangle Bubble Chat iOS Swift 5

Hello all, every week I try to give you a good tutorial to add your skill and knowledge too. And today you got to be suprised because It's not usually tutorial. I need to dig it deep down to present it. So if you want to create chat application, it's good for you. You can take it as reference.

So in chat application, you will face chat from bottom to up. As a screenshoot above, you can see it's not from top to bottom but otherwise. There is bubble chat on left and right. You can say when you send it will be on right and when someone send, it will be on left.

And about text height, it must be flexible height. Like app chat line or whatsapp, there is no cut in height. So it can small or so high. So we need to calculate the height. And about the width it's not full, we give space to the right or left.

I include the title header too so It will be more like chat app. The header will be on viewForFooterInSection why ? Because I reverse the UITableview, so the chat will be on bottom to top. As you can see on image above.

I create UIlabel date after message like chat app usually. So it will be complete for you to implement. And sorry if I don't give you full Source Code because it's easy to follow when you the code. So this is the code..

Wednesday, October 16, 2019

Double Tap Zoom to The Tap Location Swift 5 iOS 13

Hello, I find a problem where user wants to zoom to the tap location in ImageView. Actually ImageView inside UIScrollview. Because it's not just zoom when double tap but user can zoom manually with pinning. So basically it's like gallery album in iPhone, you can see it.

When I try find the way on the internet, it doesn't work like the way I want. Double tap to zoom working but it just zoom on the center not to the tap location. You need to combine UIScrollview with UIImageview to use gesture zoom. Because UIImageview itself doesn't use scrollview so it will not effect scrollview.

Maybe in iOS version before 13 the way on the internet it works. Because I see some posting get upvote and every comment say it works. But in new version of iOS we need to check again. So it's like swift version language. It has developed better again.

So I finally combine answer on the internet to make what I want. So  this is the code

Tuesday, October 8, 2019

Avoid Create Multiple Album in iOS Swift 5

Do you ever have an application that can download photo from your app to your album gallery ? It's not so complicated to do it, if you have the library that I will share to you right now. When you save your photo sometimes you need to create the album first then put the images in there. So It's neat too look. You can name your album with name of your app name.

So the trick is everytime user will download you call create album method. In this method you check first if there's an same album created or not. If it's not then creating new one otherwise don't create. Because in iOS create same name, it's permitted. So it will be bad if you create many albums with same name.

And if you reinstall the app, maybe the app will create the same album if you don't check. So it's our job as programmer to handle it. To make the user doesn't need to delete the same album. I personally want to know the way before I didn't reliaze that my app create multiple albums after I check it manually. So after I found it multiple, I try to find the way on the internet and finally it's not hard to do.

Tuesday, October 1, 2019

Solution UIViewController Not Full Screen in iOS 13 ( Bonus My Extension )

Good october month all.

Have you installed iOS 13 in your device and you get suprise that some of your views have a gap on the top like picture above. It's bad or good news for us developer iOS. First it looks new and some people may love or hate it but in iOS 13 it becames default system to use it. You need to change it manually every view controller, if you have many it becames many job to do it.

Why we need to change it back to fullscreen, because I have view that has not to come back to previous view. It will be bad for user expirience to swipe up and go back and what they get only splashscreen and don't go anywhere again. It needs to reopen app again. This is my case in my apps.

Fortunely it's not hard to change it back to fullscreen again. It just needs one line code to change it but if you have function everytime you do presenting view controller. You just need to add one single line to make it fullscreen but if you have many present function in many classes. Good luck for you to change it one by one ok.

So this is the code you have to add. Of course you can find it online by google, but i need to tell you the best way is you use fullscreen. And I will give you my extension to present and dismiss with animation. Here we go...