I share some contents using the following code
var textToShare = "Test"
let activityVC = UIActivityViewController(activityItems: [textToShare], applicationActivities: nil)
activityVC.excludedActivityTypes = [UIActivityTypePrint, UIActivityTypeCopyToPasteboard, UIActivityTypeAssignToContact]
presentViewController(activityVC, animated: true, completion: nil)
But when I press the cancel button or when the content is shared successfully, the App shows a blank screen.
How to fix this issue ?
UPDATE:
The blank screen just appears when I select mail or sms apps for the sharing target, For Telegram, Twitter and Facebook it is working perfect.
I commented all the code inside lifecycle methods, Still same issue.
override func viewDidAppear(animated: Bool)
{
//setControlsAreHidden(true)
}
override func viewWillAppear(animated: Bool)
{
//if dataAddedToView
//{
// activityIndicator?.removeFromSuperview()
//}
}
override func viewWillDisappear(animated: Bool)
{
//setControlsAreHidden(false)
}
I was having this same problem, and was able to solve it by adjust the sizing constraints of my primary UIView.
Code before:
override func loadView() {
self.view = UIView()
self.view.translatesAutoresizingMaskIntoConstraints = false
}
Code after:
override func loadView() {
self.view = UIView()
}
So just remove self.view.translatesAutoresizingMaskIntoConstraints = false
This might not apply to everyone, but based on other peoples' answers, I gather there are various issues with how views are displayed which can cause the same problem. If my fix doesn't work for you, I suggest commenting out all unnecessary code until the problem goes away, and then methodically bring small bits back online, testing along the way to identify your issue.
As you are presenting MFMailComposeViewController
and MFMessageComposeViewController
above your current UIViewController
so when you dismiss the MFMailComposeViewController
or MFMessageComposeViewController
after sending the message then your UIViewController
viewWillAppear
method will be called as the view is appearing again, so in my opinion check in viewWillAppear
or viewWillDisappear
method whether you are making your view nil
.
I don't see any calls to the super implementation in your viewDidAppear, viewWillAppear or viewWillDisappear methods.
What happens if you do?:
override func viewDidAppear(animated: Bool)
{
super.viewDidAppear(animated)
//setControlsAreHidden(true)
}
override func viewWillAppear(animated: Bool)
{
super.viewWillAppear(animated)
//if dataAddedToView
//{
// activityIndicator?.removeFromSuperview()
//}
}
override func viewWillDisappear(animated: Bool)
{
super.viewWillDisappear(animated)
//setControlsAreHidden(false)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With