Skip to content

UIKit sheets, popovers, alerts, activities, and pickers

Presentation style communicates the relationship between the current task and the next one. Push for deeper hierarchy. Present a sheet for focused work. Use a popover for contextual choices. Reserve alerts for decisions that need immediate attention.

Present from an owning controller

@MainActor
func presentEditor(for noteID: NoteID?) {
let editor = NoteEditorViewController(noteID: noteID, library: library)
let navigation = UINavigationController(rootViewController: editor)
navigation.modalPresentationStyle = .pageSheet
present(navigation, animated: true)
}

The presenting controller belongs to the active hierarchy. A detached controller cannot reliably present system UI. The editor owns Save and Cancel behavior, including unsaved-change policy.

Adapt popovers explicitly

let controller = TagActionsViewController(tag: tag)
controller.modalPresentationStyle = .popover
controller.popoverPresentationController?.sourceView = tagButton
controller.popoverPresentationController?.sourceRect = tagButton.bounds
present(controller, animated: true)

Popover source information is required on presentations that use a popover. Compact environments may adapt it to a sheet. Test both forms.

Use system controllers for system jobs

Photo selection, document selection, sharing, mail, and browser presentation come with platform behavior, privacy handling, and accessibility. Wrap their delegate or callback result at the adapter boundary rather than rebuilding them.

let activity = UIActivityViewController(
activityItems: [exportURL],
applicationActivities: nil
)
present(activity, animated: true)

An activity item must not expose private content the user did not select. iPad presentation and completion outcomes need explicit handling.

Keep alerts precise

An alert names the exact consequence and actions. “Delete Creek crossing?” is better than “Are you sure?” Destructive confirmation is not a substitute for Undo when recovery is feasible.

Validation boundary

The snippets were not compiled or presented. Adaptive sheets, popovers, system pickers, privacy prompts, activity completion, and accessibility remain Not verified.

Series navigation

References