#UIActivityViewController
Explore tagged Tumblr posts
douglashill · 5 months ago
Text
iOS app sending emails cheatsheet:
If you need attachments, use MFMailComposeViewController
If you need Mac Catalyst, use mailto URLs
If you need both attachments and Mac Catalyst, use ShareLink/UIActivityViewController
If you don’t need either, pick one based on the UX
0 notes
jacob-cs · 7 years ago
Video
youtube
UIActivityViewController 기초설명
UIActivityViewController 를 이용 text, image를 다른 앱에 share할수 있게 한다.
0 notes
ios-goodies · 6 years ago
Text
Week 274
Happy Thursday! One of the goals of iOS Goodies has always been to bring forward new faces in our community. For more than 4 years, iOS Goodies has been open source, and anyone could submit their content to the newsletter. I know there's still room for improvement, but I'm also very happy with the community we have around iOS Goodies and with all the people whose work we've featured in our newsletter. Still, we'd like to showcase the work of people who don't have a very big audience yet and help them share their knowledge with more developers. And we're not the only ones :). Dave Verwer has created iOS Dev Directory, a place that features an impressive list of sites about iOS development topics. You can add your own there, or use it to get to know more people in our community.
Speaking of bringing forward new people in our community, there's still time to apply for a WWDC scholarship. If you're a student or a member of a STEM organization, you can apply for a scholarship that will cover the WWDC ticket cost and acommodation for the event. Paul Hudson has an interview with previous WWDC scholarship winners who give their advice on how to do it.
Articles
How to find memory leaks in an iOS app, by Tim Miko
Deep dive into Pattern matching with ~= operator, by @mecid
Embracing the Limits of UIActivityViewController, by @Swanros
How to Test UIAlertController, by @joemasilotti
Custom Transitions Using Segues, by @dagostin
Serialisation of enum with associated type, by @dmtopolog
Tools/Controls
swift-log, by Apple
MetricPrefixNumberFormatter - NSNumberFormatter subclass designed to format large and small numbers using the metric prefixes, by @rostyslav_d
PanModal - PanModal is an elegant and highly customizable presentation API for constructing bottom sheet modals on iOS, by @tosinaf and @StephenSowole
Business/Career
So You Want to Be an Engineer, by Matt Dole
Blog about Swift: Tips and ideas to start your own, by @twannl
UI/UX
Dos and Don’ts for creating an onboarding journey on iOS, by @BenoitPasquier_
Everything you need to know about Loading Animations, by @LisaDziuba
Humane by Design, by @JonYablonski
Videos
RxSwift & MVVM: Your First Steps (in Hebrew, enable subtitles), by @freak4pc
Credits
LisaDziuba, pmusolino, popei69, RenGate, rbarbosa, co16353sidak, mecid, DmIvanov, mikina
2 notes · View notes
goodorbetterprogrammer · 3 years ago
Text
HackingWithSwift Day 22
Introduction to UIActivityViewController
let vc = UIActivityViewController(activityItems: [image], applicationActivities: []) vc.popoverPresentationController?.barButtonItem = navigationItem.rightBarButtonItem present(vc, animated: true)
You can add any item you want to the activityItemsArray, and popoverPresentationController code is needed for iPad , if the app only target iPhone then you can omit this part but best to provide it
There isn’t much to write about Project 3 , aside from the @objc tag for selector, which may need more research to know about it.
0 notes
fbreschi · 6 years ago
Text
How To Share Content From Your App With UIActivityViewController in Swift
http://bit.ly/33mSPaL
0 notes
arthurknopper · 6 years ago
Text
Activity View Controller iOS Tutorial
The Activity View Controller  is a standard view controller that can be used to offer various services from the application. The system provides several standard services, such as copying items to the pasteboard, posting content to social media sites, sending items via email or iMessage, and more. In this tutorial, an image will be saved to the Photo Library in the simulator. This tutorial is made with Xcode 10 and built for iOS 12.
Open Xcode and create a new Single View App.
For product name, use IOSActivityViewControllerTutorial and then fill out the Organization Name and Organization Identifier with your customary values. Enter Swift as Language and choose Next.
For this tutorial an image is needed. Download the image. Open the Assets folder and drag the downloaded image to it. 
Go to the Storyboard and select the View Controller. Go to the Editor menu and select Embed in -> Navigation Controller
Drag an Image View to the main view. Select the image View and go to the Attribute Inspector. In The Image View section select the image name in the Image field.
Select the Resolve Auto Layout Issues button and select Reset to Suggested Constraints.
The Storyboard should look like this.
Select the Assistant Editor and make sure the ViewController.swift is visible. Ctrl and drag from the Image View to the ViewController class and create the following Outlet
Change the viewDidLoad method to 
override func viewDidLoad() { super.viewDidLoad() navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .action, target: self, action: #selector(shareImage)) }
A system action button is assigned to the navigation bar. When clicked the shareImage method will be called. Implement this method.
@objc func shareImage() { let vc = UIActivityViewController(activityItems: [imageView.image!], applicationActivities: []) present(vc, animated: true) }
An Activity View Controlller is created and presented with the image view as an acitvity item. The image will be saved to the Photo Library so the user must be granted the permission to access the Photo Library. Open the Info.plist and add a new row. Select "Privacy - Photo Library Additions Usage Description" and fill in a custom text in the adjacent String filed.
Build and Run the project. Select the Action button in the Navigation bar to display the Activitiy View.
Select "Save Image" and Choose OK to grant the application access to the Photo Library. The photo will be added to the Photo Library.
You can download the source code of the IOSActivityViewControllerTutorial at the ioscreator repository on Github.
0 notes
iyarpage · 6 years ago
Text
UIActivityViewController Tutorial: Sharing Data [FREE]
In this UIActivityViewController tutorial, you’ll learn all about giving your users the ability to export their data and share it with others. UIActivityViewController Tutorial: Sharing Data [FREE] published first on https://medium.com/@koresol
0 notes
cdemiranda · 6 years ago
Link
via Ray Wenderlich
0 notes
jmpgames-blog · 7 years ago
Text
Version 0.19b
In the last version, I tried to add a RevealViewController in order to display confirmation of what you stopped it at, and where it would have stopped. As you may have read. I couldn't get this to work. The code remains and it’s definitely something I’m planning on coming back to, however, right now I’ve decided that getting the game completed is more important than a feature which, although nice, isn’t required for the game to function.
Having said that. Neither is the ability to share your score on social media. But hey, this feature was always part of the plan. The RevealViewController wasn’t.
Sharing is going to happen after the game has finished. So it makes sense that everything happens on this ViewController.
I'm going to start by creating a ‘Share Score’ button and attached it to the FinalViewController. 
Tumblr media
In iOS 11, Apple has updated the way in which you are able to share to different places. Previously, you would have had to make a new function for each sharing option, then authenticate and check for details etc. Now it is much much easier. I created a new string called ‘socialMessage’ with no data. Then when I press the ‘share score’ button the first thing I do is set socialMessage to be my message that I want to send out. In this case:
socialMessage = "I played 'Hold Your Nerve' and got a score of " + StringToSegue + "! Can you beat me?"
Where StringToSegue is the final score that was passed over from the GameViewController.
Then I created a new UIActivityViewController called shareSheet. There are two options here: activityItems and applicationActiviities. activiityItems needs to be saved as an array, so within this array I’ve added socialMessage and an image containing the games logo. I then present the shareSheet.
That's it. Literally. If the user has Facebook, Twitter, Whatsapp installed the shareSheet will allow them to post to those various other applications. No other code required. It will also allow you to use this info with all of Apple built-in functions such as Message, Email, Print, AirDrop, Copy, Save to camera roll, Assign to contact etc. Whilst some of these are good and I want to include. Others aren’t appropriate. You can use the ‘excludeActivityTypes’ module to remove certain features from the UIActivityController. I removed the following from mine:
UIActivityType.print, UIActivityType.assignToContact, UIActivityType.copyToPasteboard,UIActivityType.saveToCameraRoll, UIActivityType.airDrop
You can see the outcome of the shareSheet below.
Tumblr media
The only issue with this is Facebook. The Facebook API doesn’t allow you to populate the field with text that the user didn't write themselves. You can however still push an image or hashtags.
Tumblr media Tumblr media Tumblr media Tumblr media
Really simple and straightforward. The message is a little basic, so I added the link to my website: https://jmpgames.online I did this by creating an NSURL called URL, then adding URL to the array of things to share. This ended up being quite a lot, so, I removed the image as the weblink is far more important. 
       let shareSheet = UIActivityViewController(activityItems: [socialMessage, URL as Any], applicationActivities: nil)
This then got me thinking. Looking at other apps, they have a way to share info about the app from the main menu. So, I decided my app should do the same. I decided to create a new ViewController called ContactViewController. Here I’m going to have buttons that take you directly to the Website, Facebook page and Twitter feed.
I created a new ViewController called ContactViewController and set up the relevant segues and buttons.
Tumblr media
The next thing was to decide how to display these web pages. I could have done this simply by making the app close and opening facebook, twitter, safari in order to display the relevant pages. However, I decided to use an SFSafariViewController in order to display a safari page from within my app. 
I create three variables, each one of type NSURL: webURL, facebokURL and twitterURL, each with the link to the correct page.
Within each of the buttons, I created a new SFSafariViewController called webVC. I passed the variables I just created to each one and used the present feature to display the new webVC. The code for  displaying the website is shown below:
let webVC = SFSafariViewController(url: webURL! as URL)        present(webVC, animated: true, completion: nil)
You can view the contact page here:
youtube
0 notes
ttwgroup · 7 years ago
Photo
Tumblr media
We are nearing the end of the development process on our new fitness app, Milestone. One of the last features to be implemented is sharing though a UIActivityViewController. The primary service we wanted to test was Instagram but we immediately noticed issues with the UI. It seemed like a portion of our own UI was showing through, almost like the Instagram share screen was partially transparent. Other services may have been affected, but Instagram was the only one I could confirm.
After comparing with other apps that share to Instagram we were able to narrow down the issue. We were setting prefersLargeTitles on our UINavigationBar objects using the UIAppearance protocol. Turns out that Instagram was respecting this choice from our app, but it was clearly not designed for it, causing the transparency bug. We updated our code to set prefersLargeTitles only where we needed it and Instagram was back working as it should.
If you'd be interested in joining the beta for Milestone Fitness get in touch with @thinktapwork.
0 notes
lesterwilliams1 · 8 years ago
Text
50% off #Rume Academy – Make a monetized iOS Pop A Lock game in Swift – $10
Learn how to make your own Pop A Lock game in iOS using Xcode 7 and Swift 2 using SpriteKit, iAd + source code included
All Levels,  –   Video: 1 hour,  13 lectures 
Average rating 4.3/5 (4.3)
Course requirements:
A Mac or PC running OSX (min. Yosemite) Download Xcode 7 for free from the Mac Appstore
Course description:
Do you want to become a cash earning game developer in just under 60 minutes?
Then you have come to the right course.
We are here to teach you how to easily build your first game.
It will be called Pop A Lock and it comes with integrated ads so you can earn real money.
The full source code is included for each lesson and of course for the finished project!
In these 60 minutes of Swift 2 you will learn:
How to use SpriteKit Create a game flow, save game states and use a protocol to communicate them Use iAd to monetize the final product so you can earn real money with your game! Implement a screenshot sharing function to help your app gain popularity on social media
This course is a great way for anybody to get started with Swift 2 and Sprite Kit development because the entire course will take under 60 minutes to be finished.
So take this course, make your first fully monetized game, submit it to the app store and become a cash earning developer today.
We hope to see you in the course!
Full details Create their own Pop A Lock game in iOS Use SpriteKit and its basic elements to build awesome games Monetize an application using iAd Take a screenshot of the game Use an UIActivityViewController to share an image Use NSUserDefaults to store data permanently Write custom extensions Be ready to submit their game to the iOS appstore
Full details This course is for anyone who wants to develop games for iOS Prior programming experience is NOT needed, but could speed up the progress Anybody excited about Swift 2 and using it to build awesome applications is at the right place
Reviews:
“it’s great so far, a little fast and not very explainy but if you already have experience with spritekit it’s a good tutorial.” (Devon Chase)
“Clear instructions and fun to app to make. Could have been 30 minutes longer to explain things in better detail.” (Cody Bonnett)
“I started building a Pop A Lock style game and end up with a totally new game that is on AppStore! https://itunes.apple.com/us/app/void-black-hole-space-mission/id1097436513?ls=1&mt=8 Before this course I didn’t even knew how to start to develop anything… So thank you very much for this!” (Bruno Bihari)
    About Instructor:
Johannes Ruof
I study Applied Computer Science and teach at the university and here on udemy. I have been developing iOS applications for over 3 years and have 5 years of experience in Objective C Programming. Since Apple announced Swift I have been using it in my programming and can proudly say I have experience since Day 1 of the language. I am looking forward to sharing my knowledge with my students and hopefully have a positive impact on the lifes of as many people as possible as much as learning new things myself. “You are never too old to set another goal or to dream a new dream.” – C. S. Lewis
I’m currently studying economics and work as a teacher on Udemy. I have worked in digital publishing and viral marketing for more than three years. I am also a web and mobile application developer with almost four years of working experience. But my greatest passion is designing and developing mobile games for iOs devices, in either Objective C or Swift. My teaching philosophy is best described in the words of Benjamin Franklin: “Tell me and I forget. Teach me and I remember. Involve me and I learn.” I hope that we can create many beautiful things together and learn from each other.
Instructor Other Courses:
Programmieren Lernen – Swift 3 für Einsteiger Programmieren Lernen – Swift 3 für Einsteiger Learn How To Code – Professional Swift Development For iOS Learn How To Code – Professional Swift Development For iOS Programmieren lernen: Swift von A bis Z Programmieren lernen: Swift von A bis Z …………………………………………………………… Johannes Ruof coupons Development course coupon Udemy Development course coupon Mobile Apps course coupon Udemy Mobile Apps course coupon Rume Academy – Make a monetized iOS Pop A Lock game in Swift Rume Academy – Make a monetized iOS Pop A Lock game in Swift course coupon Rume Academy – Make a monetized iOS Pop A Lock game in Swift coupon Timothy Meixner coupons
The post 50% off #Rume Academy – Make a monetized iOS Pop A Lock game in Swift – $10 appeared first on Udemy Cupón.
from Udemy Cupón http://www.xpresslearn.com/udemy/coupon/50-off-rume-academy-make-a-monetized-ios-pop-a-lock-game-in-swift-10/
from https://xpresslearn.wordpress.com/2017/02/24/50-off-rume-academy-make-a-monetized-ios-pop-a-lock-game-in-swift-10/
0 notes
xpresslearn · 8 years ago
Text
50% off #Rume Academy – Make a monetized iOS Pop A Lock game in Swift – $10
Learn how to make your own Pop A Lock game in iOS using Xcode 7 and Swift 2 using SpriteKit, iAd + source code included
All Levels,  –   Video: 1 hour,  13 lectures 
Average rating 4.3/5 (4.3)
Course requirements:
A Mac or PC running OSX (min. Yosemite) Download Xcode 7 for free from the Mac Appstore
Course description:
Do you want to become a cash earning game developer in just under 60 minutes?
Then you have come to the right course.
We are here to teach you how to easily build your first game.
It will be called Pop A Lock and it comes with integrated ads so you can earn real money.
The full source code is included for each lesson and of course for the finished project!
In these 60 minutes of Swift 2 you will learn:
How to use SpriteKit Create a game flow, save game states and use a protocol to communicate them Use iAd to monetize the final product so you can earn real money with your game! Implement a screenshot sharing function to help your app gain popularity on social media
This course is a great way for anybody to get started with Swift 2 and Sprite Kit development because the entire course will take under 60 minutes to be finished.
So take this course, make your first fully monetized game, submit it to the app store and become a cash earning developer today.
We hope to see you in the course!
Full details Create their own Pop A Lock game in iOS Use SpriteKit and its basic elements to build awesome games Monetize an application using iAd Take a screenshot of the game Use an UIActivityViewController to share an image Use NSUserDefaults to store data permanently Write custom extensions Be ready to submit their game to the iOS appstore
Full details This course is for anyone who wants to develop games for iOS Prior programming experience is NOT needed, but could speed up the progress Anybody excited about Swift 2 and using it to build awesome applications is at the right place
Reviews:
“it’s great so far, a little fast and not very explainy but if you already have experience with spritekit it’s a good tutorial.” (Devon Chase)
“Clear instructions and fun to app to make. Could have been 30 minutes longer to explain things in better detail.” (Cody Bonnett)
“I started building a Pop A Lock style game and end up with a totally new game that is on AppStore! https://itunes.apple.com/us/app/void-black-hole-space-mission/id1097436513?ls=1&mt=8 Before this course I didn’t even knew how to start to develop anything… So thank you very much for this!” (Bruno Bihari)
    About Instructor:
Johannes Ruof
I study Applied Computer Science and teach at the university and here on udemy. I have been developing iOS applications for over 3 years and have 5 years of experience in Objective C Programming. Since Apple announced Swift I have been using it in my programming and can proudly say I have experience since Day 1 of the language. I am looking forward to sharing my knowledge with my students and hopefully have a positive impact on the lifes of as many people as possible as much as learning new things myself. “You are never too old to set another goal or to dream a new dream.” – C. S. Lewis
I’m currently studying economics and work as a teacher on Udemy. I have worked in digital publishing and viral marketing for more than three years. I am also a web and mobile application developer with almost four years of working experience. But my greatest passion is designing and developing mobile games for iOs devices, in either Objective C or Swift. My teaching philosophy is best described in the words of Benjamin Franklin: “Tell me and I forget. Teach me and I remember. Involve me and I learn.” I hope that we can create many beautiful things together and learn from each other.
Instructor Other Courses:
Programmieren Lernen – Swift 3 für Einsteiger Programmieren Lernen – Swift 3 für Einsteiger Learn How To Code – Professional Swift Development For iOS Learn How To Code – Professional Swift Development For iOS Programmieren lernen: Swift von A bis Z Programmieren lernen: Swift von A bis Z …………………………………………………………… Johannes Ruof coupons Development course coupon Udemy Development course coupon Mobile Apps course coupon Udemy Mobile Apps course coupon Rume Academy – Make a monetized iOS Pop A Lock game in Swift Rume Academy – Make a monetized iOS Pop A Lock game in Swift course coupon Rume Academy – Make a monetized iOS Pop A Lock game in Swift coupon Timothy Meixner coupons
The post 50% off #Rume Academy – Make a monetized iOS Pop A Lock game in Swift – $10 appeared first on Udemy Cupón.
from http://www.xpresslearn.com/udemy/coupon/50-off-rume-academy-make-a-monetized-ios-pop-a-lock-game-in-swift-10/
0 notes
lewiskdavid90 · 8 years ago
Text
50% off #Rume Academy – Make a monetized iOS Pop A Lock game in Swift – $10
Learn how to make your own Pop A Lock game in iOS using Xcode 7 and Swift 2 using SpriteKit, iAd + source code included
All Levels,  – 1 hour,  13 lectures 
Average rating 4.1/5 (4.1 (110 ratings) Instead of using a simple lifetime average, Udemy calculates a course’s star rating by considering a number of different factors such as the number of ratings, the age of ratings, and the likelihood of fraudulent ratings.)
Course requirements:
A Mac or PC running OSX (min. Yosemite) Download Xcode 7 for free from the Mac Appstore
Course description:
Do you want to become a cash earning game developer in just under 60 minutes?
Then you have come to the right course.
We are here to teach you how to easily build your first game.
It will be called Pop A Lock and it comes with integrated ads so you can earn real money.
The full source code is included for each lesson and of course for the finished project!
In these 60 minutes of Swift 2 you will learn:
How to use SpriteKit Create a game flow, save game states and use a protocol to communicate them Use iAd to monetize the final product so you can earn real money with your game! Implement a screenshot sharing function to help your app gain popularity on social media
This course is a great way for anybody to get started with Swift 2 and Sprite Kit development because the entire course will take under 60 minutes to be finished.
So take this course, make your first fully monetized game, submit it to the app store and become a cash earning developer today.
We hope to see you in the course!
Full details Create their own Pop A Lock game in iOS Use SpriteKit and its basic elements to build awesome games Monetize an application using iAd Take a screenshot of the game Use an UIActivityViewController to share an image Use NSUserDefaults to store data permanently Write custom extensions Be ready to submit their game to the iOS appstore
Full details This course is for anyone who wants to develop games for iOS Prior programming experience is NOT needed, but could speed up the progress Anybody excited about Swift 2 and using it to build awesome applications is at the right place
Reviews:
“I started building a Pop A Lock style game and end up with a totally new game that is on AppStore! https://itunes.apple.com/us/app/void-black-hole-space-mission/id1097436513?ls=1&mt=8 Before this course I didn’t even knew how to start to develop anything… So thank you very much for this!” (Bruno Bihari)
“Nice course to show how to develop game app. Not really for beginners as there are not enough explanation of the codes being written.” (Weifan Huang)
“Excellent concrete example to give starters an idea of what can be done with swift in a couple hours. Requires basic knowledge of swift Thanks! Edit: after looking into Q&A, i saw instructor(s) is(are) answering all question, it deserves a perfect rating!” (Brice)
  About Instructor:
Johannes Ruof Timothy Meixner
I study Applied Computer Science and teach at the university and here on udemy. I have been developing iOS applications for over 3 years and have 5 years of experience in Objective C Programming. Since Apple announced Swift I have been using it in my programming and can proudly say I have experience since Day 1 of the language. I am looking forward to sharing my knowledge with my students and hopefully have a positive impact on the lifes of as many people as possible as much as learning new things myself. “You are never too old to set another goal or to dream a new dream.” – C. S. Lewis
I’m currently studying economics and work as a teacher on Udemy. I have worked in digital publishing and viral marketing for more than three years. I am also a web and mobile application developer with almost four years of working experience. But my greatest passion is designing and developing mobile games for iOs devices, in either Objective C or Swift. My teaching philosophy is best described in the words of Benjamin Franklin: “Tell me and I forget. Teach me and I remember. Involve me and I learn.” I hope that we can create many beautiful things together and learn from each other.
Instructor Other Courses:
iOS Development – Create 4 Quiz Apps with Swift 3 & iOS 10 Johannes Ruof, RUME Academy (14) $10 $150 iOS Development – Create 4 Quiz Apps with Swift 3 & iOS 10 Johannes Ruof, RUME Academy (14) $10 $150 iOS Entwicklung – Entwickle Quiz Apps mit Swift 3 und iOS 10 iOS Entwicklung – Entwickle Quiz Apps mit Swift 3 und iOS 10 Programmieren Lernen – Swift 3 für Einsteiger Programmieren Lernen – Swift 3 für Einsteiger …………………………………………………………… Johannes Ruof Timothy Meixner coupons Development course coupon Udemy Development course coupon Mobile Apps course coupon Udemy Mobile Apps course coupon Rume Academy – Make a monetized iOS Pop A Lock game in Swift Rume Academy – Make a monetized iOS Pop A Lock game in Swift course coupon Rume Academy – Make a monetized iOS Pop A Lock game in Swift coupon coupons
The post 50% off #Rume Academy – Make a monetized iOS Pop A Lock game in Swift – $10 appeared first on Course Tag.
from Course Tag http://coursetag.com/udemy/coupon/50-off-rume-academy-make-a-monetized-ios-pop-a-lock-game-in-swift-10/ from Course Tag https://coursetagcom.tumblr.com/post/157327190528
0 notes
arthurknopper · 7 years ago
Text
Airdrop iOS Tutorial
In iOS 7, Apple introduced a new feature called AirDrop. With AirDrop, you can easily share data with other nearby iOS devices. AirDrop uses Bluetooth to scan for nearby devices. When a connection is established via Bluetooth, it’ll create an ad-hoc Wi-Fi network to link the two devices together. In this tutorial we will share a picture between two devices using Airdrop. This tutorial is made with Xcode 10 and built for iOS 12.
Open Xcode and create a new Single View App.
For product name, use iOSAirdropTutorial and then fill out the Organization Name and Organization Identifier with your customary values. Enter Swift as Language and choose Next
Go to the Storyboard and drag an Image View to the main View. Select the Image View and go to the Size inspector and fill in the following values.
Drag a button from the Object Library to the main view and place it beneath the Image View. Change the Title to "Share". Select the "Resolve Auto Layout" button from the bottom-right in the Storyboard and select "Reset to Suggested Constraints".
The Storyboard should look like this.
Select the Assistant Editor and make sure the ViewController.swift is visible. Ctrl and drag from the Image View and create the following Outlet.
Ctrl and drag from the "Share" Button to the ViewController class and create the following Action.
Download the image and add it to the project. Change the viewDidLoad method to
override func viewDidLoad() { super.viewDidLoad() let image = UIImage(named:"imac.jpg") imageView.image = image }
Implement the shareImage method
@IBAction func shareImage(_ sender: Any) { let image = imageView.image! let controller = UIActivityViewController(activityItems: [image], applicationActivities: nil) controller.excludedActivityTypes = [.postToFacebook, .postToTwitter, .print, .copyToPasteboard, .assignToContact, .saveToCameraRoll, .mail] self.present(controller, animated: true, completion: nil) }
The Activity Controller is a standard View Controller that displays services that your application can use. This services includes Airdrop, Mail, Post to Twitter, etc. In this tutorial only the Airdrop service will be needed, so the other services are excluded. Build and Run the project, press the share button and the Airdrop button. The image can then be transferred to another device. The iOS simulator doesn't have a Airdrop functionality, so this project should be built onto a real device.
You can download the source code of the IOSAirdropTutorial at the ioscreator repository on Github.
0 notes
lessthanuthink · 10 years ago
Text
Dark Cocoa: How to display an iOS share sheet with AirDrop as the only option
Last week I was working on a feature for a new app which involves sharing some data between two devices (encoded in a URL to link into the app on the receiver’s device) — with the catch being that the transfer has to happen over AirDrop (trust me, there’s a good reason for it). I eventually got an AirDrop-only share sheet working, but I thought it’d be fun (and hopefully interesting) to dig into the process I went through in figuring it out.
Now since Apple doesn’t provide a way to access AirDrop directly, I had to go through UIActivityViewController. My first thought was to use its excludedActivityTypes property and just load up an array with every activity type listed in UIActivity.h (other than AirDrop). That works great… except when you come to iOS 8’s third-party app extensions.
My next idea was to just put together a list of some of the more popular share extension identifiers and add those to the excludedActivityTypes array. This wouldn’t have been a great solution, as there would always be extensions slipping through (and it wouldn’t have worked at all, as it turns out). Though this line of thought did lead me to what I thought was a very clever idea…
I suspected (and a quick trip to the debugger verified that I was right) that UIActivityViewController was just checking each extension identifier against the excludedActivityTypes array — so what if I passed its setter a trick NSArray subclass which would have a containsObject: method that returned NO to any object other than UIActivityTypeAirDrop? This worked like a charm for hiding all of the system-provided sharing options, but despite the fact that the array was checked for each third-party share extension’s identifier, the results of that check were ignored. I was disappointed that I’d have to scrap what I thought was a clever and elegant solution.
Okay, so it was time to go deeper. I took a look at some iOS 8 runtime headers, subclassed UIActivityViewController, and started to play around with some private instance variables in the debugger… and _activityGroupListViewController proved to be the winner.
Its two arrays, _activityGroupViewControllers and _visibleActivityGroupViewControllers, when run on an AirDrop-capable device, contained an object of an interesting sounding class: SFAirDropActivityViewController. By removing any other view controllers from those arrays (and hiding their views) I was left with an AirDrop-exclusive share sheet. All that was left to do was alter that UIActivityGroupListViewController’s preferredContentSize and disable scrolling on its collection view and — ✨ta-da! ✨— a pretty straightforward way to AirDrop something.
Tumblr media
I’ve shared my complete solution on GitHub, but remember: these sorts of tricks should really be a last resort, and could potentially break with any system update — use them at your own risk.
0 notes
developing-io · 10 years ago
Text
Add a Sharing Option to your App
This article will guide you about how to add a sharing option to your application.
For example the code below will share an integer value which is included in an NSString.  Furthermore it´s important that you can share multiple objects through the array. 
Sample Code:
NSString *string; string = [NSString stringWithFormat:@"Shared Integer", myinteger]; NSArray *objectsToShare = @[string]; UIActivityViewController *controller = [[UIActivityViewController alloc] initWithActivityItems:objectsToShare applicationActivities:nil]; [self presentViewController:controller animated:YES completion:nil];
0 notes