0
0
iOS Swiftmobile~5 mins

Share sheet (UIActivityViewController) in iOS Swift - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is UIActivityViewController used for in iOS development?
UIActivityViewController is used to present a share sheet that lets users share content like text, images, or URLs with other apps or services.
Click to reveal answer
beginner
How do you initialize a UIActivityViewController with items to share?
You create it by passing an array of items (like strings or images) to the initializer: UIActivityViewController(activityItems: [items], applicationActivities: nil).
Click to reveal answer
intermediate
Why should you set the popoverPresentationController?.sourceView on iPad when using UIActivityViewController?
On iPad, the share sheet appears as a popover. Setting sourceView tells iOS where to anchor the popover, preventing crashes and ensuring correct display.
Click to reveal answer
intermediate
Can you customize the activities shown in the share sheet?
Yes, by providing custom UIActivity objects in the applicationActivities parameter or excluding some built-in activities using excludedActivityTypes.
Click to reveal answer
intermediate
What happens after the user completes or cancels sharing in UIActivityViewController?
You can handle completion with the completionWithItemsHandler closure to know if the user shared, cancelled, or if there was an error.
Click to reveal answer
What parameter do you pass to UIActivityViewController to specify what to share?
AshareItems
BactivityItems
CcontentItems
DitemsToShare
Which property must be set on iPad to avoid a crash when presenting UIActivityViewController?
AmodalPresentationStyle
BpresentationController
Cdelegate
DpopoverPresentationController?.sourceView
How do you exclude some activities from the share sheet?
AUse a filter method
BRemove them from activityItems
CSet excludedActivityTypes property
DSet isExcluded to true
What type of data can you share using UIActivityViewController?
AText, images, URLs, and more
BOnly images
COnly text
DOnly URLs
Which closure lets you know if the user completed or cancelled sharing?
AcompletionWithItemsHandler
BshareCompletion
CdidFinishSharing
DcompletionHandler
Explain how to present a share sheet using UIActivityViewController in an iOS app.
Think about what you want to share and how to show the share sheet safely on all devices.
You got /3 concepts.
    Describe how you can customize which sharing options appear in the share sheet.
    Consider how to control the user experience by limiting or adding sharing choices.
    You got /3 concepts.