I am presenting a UIActivityViewController to share a url via WhatsApp.
Everything works fine except that the back button in the share dialog of whats app is not working. Swipe to navigate back is working.
Have a look at the screenshot to see the button I am talking about.
My code to present the activity view controller is:
let url: NSURL = NSURL(string: "http://www.google.com")!
let activityViewController = UIActivityViewController(activityItems: [url], applicationActivities: nil)
self.videoPlayerController?.presentViewController(activityViewController, animated: true, completion: nil)
Ok, I found the problem.
Somewhere in my app I configured navigation bar to use a custom back button image in the navigation globally by like this:
UINavigationBar.appearance().backIndicatorImage = UIImage(named: "back_icon")
UINavigationBar.appearance().backIndicatorTransitionMaskImage = UIImage(named: "back_icon")
After I changed it to be not globally anymore it worked:
self.navigationBar.backIndicatorImage = UIImage(named: "back_icon")
self.navigationBar.backIndicatorTransitionMaskImage = UIImage(named: "back_icon")
Thank you stack overflow.
Related
I need to exclude .saveToCameraRoll from a UIActivityViewController but it is ignoring excludedActivityTypes.
activityVC = UIActivityViewController(activityItems: [imgUrl], applicationActivities: activities)
activityVC!.excludedActivityTypes = [.saveToCameraRoll]
I also tried creating a "custom" UIActivty and exclude it:
let saveToCameraRollActivity = UIActivity.ActivityType.init(rawValue: "\(UIActivity.ActivityType.saveToCameraRoll.rawValue)")
activityVC!.excludedActivityTypes = [saveToCameraRollActivity]
Both ways have no effect, the Save Image option is still displayed. What is the point of being able to exclude activity types if they are ignored?
The header says:
// default is nil. activity types listed will not be displayed
excludedActivityTypes: [UIActivity.ActivityType]?
I need to use my own Save Image because standard one is not respecting the file name (even though it is shown with the file icon and I am using a URL).
I am using this function and hide "save video" button :--
func otherShare(url : URL) {
let imageToShare = [ url ]
let activityViewController = UIActivityViewController(activityItems: imageToShare, applicationActivities: nil)
activityViewController.popoverPresentationController?.sourceView = self.view // so that iPads won't crash
activityViewController.excludedActivityTypes = [UIActivity.ActivityType.copyToPasteboard, UIActivity.ActivityType.saveToCameraRoll]
self.present(activityViewController, animated: true, completion: nil)
}
I want to add the my app sharing feature in my App. Like The Action Sheet Toggle up with the all the social Media and other app in which i can share my app Url. I try to find the tutorial for that but i can't find the proper tutorial for that. this is what I have Done.
func shareApp (){
let textToShare = "Swift is awesome! Check out this website about it!"
if let myWebsite = NSURL(string: "http://www.google.com/") {
let objectsToShare = [textToShare, myWebsite] as [Any]
let activityVC = UIActivityViewController(activityItems: objectsToShare, applicationActivities: nil)
activityVC.excludedActivityTypes = [UIActivityType.airDrop, UIActivityType.addToReadingList]
self.present(activityVC, animated: true, completion: nil)
}
This What i Get.
So just want to show there Some Social Media options There.
All you have done is right, except you have not added the App url of your appstore link. Add that link like https://itunes.apple.com/in/app/more-customers-app/id1280868223?mt=8 and all your media will be appear in list if those application is installed in iphone.
You have got UIActivityViewController presented now, Just add in text like,
func ShareApp()
{
let items:[Any] = ["Marketplace of Building Material for Architects, Interior Designers, Contractors and Home Owners. Find Material for your next project. Download https://itunes.apple.com/in/app/more-customers-app/id1280868223?mt=8"]
let ac = UIActivityViewController(activityItems: items, applicationActivities: nil)
self.present(ac, animated: true)
}
I want to share a url like what Safari do in my own iOS app, How can i do this?
Use socail framework can share in some specified social plartform, but in my case ,I just want to share url like Safari.
Do you think on UIActivityViewController?
#IBAction func shareTextButton(_ sender: UIButton) {
// image to share
let link = "https://www.google.rs/"
// set up activity view controller
let activityViewController = UIActivityViewController(activityItems: [link], applicationActivities: nil)
activityViewController.popoverPresentationController?.sourceView = self.view // so that iPads won't crash
// exclude some activity types from the list (optional)
activityViewController.excludedActivityTypes = [ UIActivityType.airDrop, UIActivityType.postToFacebook ]
// present the view controller
self.present(activityViewController, animated: true, completion: nil)
}
Is there any specific method to share button that detect all social media apps on your iOS phone ?
example : my phone have whatsapp and twitter installed. so when I pressed share button only whatsapp and twitter came out, not facebook and any other apps not installed on my phone.
In android there's particular intent to use that kind of method. However in iOS I still can't find it.
Note : I need it for Swift 3 programmatically
Any help is very useful, Thank you
You should try this:
#IBAction func shareImageButton(_ sender: UIButton)
{
// image to share
let image = UIImage(named: "Image")
// set up activity view controller
let imageToShare = [ image! ]
let activityViewController = UIActivityViewController(activityItems: imageToShare, applicationActivities: nil)
activityViewController.popoverPresentationController?.sourceView = self.view // so that iPads won't crash
// exclude some activity types from the list (optional)
activityViewController.excludedActivityTypes = [ UIActivityType.airDrop, UIActivityType.postToFacebook ]
// present the view controller
self.present(activityViewController, animated: true, completion: nil)
}
Im trying to implement UIActivityViewController to my app, It works correctly. However, I'd like to add Instagram to the options. When searching on the internet, I've seen this reply :
"You're able to use UIActivityViewController to show up Instagram as
long there is just an UIImage inside the activity items. It won't show
up if you add more items like text, url etc. This is a bad limitation
made by Instagram.".
Is there any way, how to add Instagram even with initial text, or should I integrate another UIActivityViewController option and turn off all of the other options (FB, Twitter, mail) to show Instagram option? Maybe through if clauses for text?
Here ist the piece of code
#IBAction func ShareRecipe(_ sender: AnyObject) {
let initialText = "-Check out this app"
let img: UIImage = ImageView.image!
let activityVC = UIActivityViewController(activityItems: [img, initialText], applicationActivities: nil)
activityVC.popoverPresentationController?.sourceView = self.view
self.present(activityVC, animated: true, completion: nil)
}