Solution Force Close When Save Image in UIActivityViewController Swift 5 iOS 13



Hello guys, It's last week for this year. And it feels so fast for me. I have started to be more consistent on this year. I started to post once every week, it's not hard for people have much time. But for me to think about what's next article need more time. I have to have a problem to make a solution haha. Tommorow will be on first day of 2020 year. It's nice to know 2019. And good bye 2019 haha.

So now the problem I faced when I was trying to save image through UIActivityViewController. After saving image the current view controller will dismiss. And it's a bug from iOS, it's confirmed on the internet stackoverflow that I give link on below. Many people faced it before me haha, thanks I know it late so that I don't need to figure it be myself haha. I hope this bug will soon be fixed by Apple. How can this bug didn't happened on iOS 12 but happed on iOS 13. I think it's because iOS 13 introduced new feature modal presentation.

We need to avoid dismissing view controller. Fortunetly I found good solution on the internet, we need to create transparant view controller and it looks clean when the current view will be dismissed. And we need to set transparant in storyboard like screenshoot above. It's simple to do, right ? then follow coding below. It's very important to understand this code to avoid error in the future.

I set background color to Clear Color. So that it will look transparant behind UIActivityViewController. And as if there's no ViewController behind it. So basically it looks same with or without Transparant view controller.

This is the code that I got :




SocialActivityItem and TextActivityItem are from my class itself. I created it to avoid sending only text on WhatsApp. If you want to know it, tell me below comment. I'm happy if you're curious to know it.

Hope you like it. And happy new year 2020. Have a good year 😀

Source : https://stackoverflow.com/a/59092554/2899321

Popular posts from this blog

How to restart the app with flutter Android and iOS

Missing system image Android Studio solution

How to have ConstraintLayout inside ScrollView and ScrollView inside ConstraintLayout Android