Closed5

【Swift】UIViewController(Child View) 0->1

yoshitakayoshitaka

カスタムコンテナでの子ビューコントローラの管理

現在のViewControllerの子であるViewControllerの配列。

var children: [UIViewController]

An array of view controllers that are children of the current view controller.

指定されたViewControllerを現在のViewControllerの子として追加します。

func addChild(UIViewController)

Adds the specified view controller as a child of the current view controller.

ビューコントローラをその親から削除します。

func removeFromParent()

Removes the view controller from its parent.

2つのViewControllerの子ViewController間の遷移。

func transition(from: UIViewController, to: UIViewController, duration: TimeInterval, options: UIView.AnimationOptions, animations: (() -> Void)?, completion: ((Bool) -> Void)?)

Transitions between two of the view controller's child view controllers.

外観メソッドが子ViewControllerに転送されるかどうかを示すブール値を返します。

var shouldAutomaticallyForwardAppearanceMethods: Bool

Returns a Boolean value indicating whether appearance methods are forwarded to child view controllers.

子コントローラーに、その外観が変更されようとしていることを通知します。

func beginAppearanceTransition(Bool, animated: Bool)

Tells a child controller its appearance is about to change.

子コントローラーに外観が変更されたことを通知します。

func endAppearanceTransition()

Tells a child controller its appearance has changed.

指定された子ViewControllerに割り当てられているトレイトを変更します。

func setOverrideTraitCollection(UITraitCollection?, forChild: UIViewController)

Changes the traits assigned to the specified child view controller.

子ViewControllerのトレイトコレクションを取得します。

func overrideTraitCollection(forChild: UIViewController) -> UITraitCollection?

Retrieves the trait collection for a child view controller.

トレイト (英: trait) とはコンピュータープログラミングにおける概念で、構造的にオブジェクト指向プログラミングを行うための簡素な概念モデルとして使われるメソッド群の集まりである。

ビューコントローラの階層がビューの階層と矛盾している場合に発生します。

class let hierarchyInconsistencyException: NSExceptionName

Raised if the view controller hierarchy is inconsistent with the view hierarchy.

yoshitakayoshitaka

Presenting a View Controller

プライマリコンテキストでViewControllerを表示します。

func show(UIViewController, sender: Any?)

Presents a view controller in a primary context.

セカンダリ(または詳細)コンテキストでビューコントローラを表示します。

func showDetailViewController(UIViewController, sender: Any?)

Presents a view controller in a secondary (or detail) context.

ビューコントローラをモーダルに表示します。

func present(UIViewController, animated: Bool, completion: (() -> Void)?)

Presents a view controller modally.

ビューコントローラによってモーダルに提示されたビューコントローラを閉じます。

func dismiss(animated: Bool, completion: (() -> Void)?)

Dismisses the view controller that was presented modally by the view controller.

モーダルビューコントローラーの表示スタイル。

var modalPresentationStyle: UIModalPresentationStyle

The presentation style for modal view controllers.

ビューコントローラを表示するときに使用できるモーダル表示スタイル。

enum UIModalPresentationStyle

Modal presentation styles available when presenting view controllers.


case automatic
// The default presentation style chosen by the system.
case none
// A presentation style that indicates no adaptations should be made.
case fullScreen
// A presentation style in which the presented view covers the screen.
case pageSheet
// A presentation style that partially covers the underlying content.
case formSheet
// A presentation style that displays the content centered in the screen.
case currentContext
// A presentation style where the content is displayed over another view controller’s content.
case custom
// A custom view presentation style that is managed by a custom presentation controller and one or more custom animator objects.
case overFullScreen
// A view presentation style in which the presented view covers the screen.
case overCurrentContext
// A presentation style where the content is displayed over another view controller’s content.
case popover
// A presentation style where the content is displayed in a popover view.
case blurOverFullScreen
// A presentation style that blurs the underlying content before displaying new content in a full-screen presentation.

ビューコントローラを表示するときに使用する遷移スタイル。

var modalTransitionStyle: UIModalTransitionStyle

The transition style to use when presenting the view controller.

ビューコントローラを提示するときに使用できる遷移スタイル。

enum UIModalTransitionStyle

Transition styles available when presenting view controllers.


case coverVertical
case flipHorizontal
case crossDissolve
case partialCurl

ビューコントローラがモーダル動作を強制するかどうかを示すブール値。

var isModalInPresentation: Bool

A Boolean value indicating whether the view controller enforces a modal behavior.

ビューコントローラまたはその子孫の1つがビューコントローラを提示するときに、このビューコントローラのビューがカバーされるかどうかを示すブール値。

var definesPresentationContext: Bool

A Boolean value that indicates whether this view controller's view is covered when the view controller or one of its descendants presents a view controller.

ビューコントローラが、表示するビューコントローラの遷移スタイルを指定するかどうかを示すブール値。

var providesPresentationContextTransitionStyle: Bool

A Boolean value that indicates whether the view controller specifies the transition style for view controllers it presents.

コントロールを変更するときに現在の入力ビューが自動的に閉じられるかどうかを示すブール値を返します。

var disablesAutomaticKeyboardDismissal: Bool

Returns a Boolean indicating whether the current input view is dismissed automatically when changing controls.

分割ビューコントローラが展開または折りたたまれたときに投稿されます。

class let showDetailTargetDidChangeNotification: NSNotification.Name

Posted when a split view controller is expanded or collapsed.

yoshitakayoshitaka

ビューコントローラのビューの推奨サイズ。

var preferredContentSize: CGSize { get set }

このプロパティの値は、主にView Controllerのコンテンツをポップオーバーで表示するときに使用されますが、他の状況でも使用される場合があります。 ビューコントローラがポップオーバーに表示されているときにこのプロパティの値を変更すると、サイズの変更がアニメーション化されます。 ただし、幅または高さを0.0に指定した場合、変更はアニメーション化されません。

yoshitakayoshitaka

カスタムトランジションまたはプレゼンテーションの追加

トランジションアニメーター、インタラクティブコントローラー、およびカスタムプレゼンテーションコントローラーオブジェクトを提供するデリゲートオブジェクト。

var transitioningDelegate: UIViewControllerTransitioningDelegate?

The delegate object that provides transition animator, interactive controller, and custom presentation controller objects.

アクティブな遷移コーディネーターオブジェクトを返します。

var transitionCoordinator: UIViewControllerTransitionCoordinator?

Returns the active transition coordinator object.

アクションに応答するViewControllerを返します。

func targetViewController(forAction: Selector, sender: Any?) -> UIViewController?

Returns the view controller that responds to the action.

現在のViewControllerを管理しているプレゼンテーションコントローラ。

var presentationController: UIPresentationController?

The presentation controller that’s managing the current view controller.

現在のViewControllerを管理している最も近いポップオーバープレゼンテーションコントローラ。

var popoverPresentationController: UIPopoverPresentationController?

The nearest popover presentation controller that is managing the current view controller.

以前にフォーカスされていたアイテムが、アイテムのView Controllerが表示されてフォーカス可能になったときに、再びフォーカスされるようにするかどうかを示すブール値。

var restoresFocusAfterTransition: Bool

A Boolean value that indicates whether an item that previously was focused should again become focused when the item's view controller becomes visible and focusable.

yoshitakayoshitaka

UIPopoverPresentationController

var popoverPresentationController: UIPopoverPresentationController? { get }

ビューコントローラまたはその祖先の1つがポップオーバープレゼンテーションコントローラによって管理されている場合、このプロパティにはそのオブジェクトが含まれます。 ビューコントローラがポップオーバープレゼンテーションコントローラによって管理されていない場合、このプロパティはnilです。

ビューコントローラを作成したがまだ表示していない場合、このプロパティにアクセスすると、modalPresentationStyleプロパティの値がUIModalPresentationStyle.popoverのときにポップオーバー表示コントローラが作成されます。 モーダル表示スタイルが異なる値の場合、このプロパティはnilです。


ポップオーバーでのコンテンツの表示を管理するオブジェクト。

class UIPopoverPresentationController : UIPresentationController

ポップオーバーが表示されてから却下されるまで、UIKitはこのクラスのインスタンスを使用して表示動作を管理します。このクラスのインスタンスをそのまま使用して、プレゼンテーションスタイルがUIModalPresentationStyle.popoverに設定されているビューコントローラーのポップオーバーの外観と動作の側面を構成します。

ほとんどすべての場合、このクラスをそのまま使用し、そのインスタンスを直接作成しません。 UIKitは、UIModalPresentationStyle.popoverスタイルを使用してView Controllerを提示すると、このクラスのインスタンスを自動的に作成します。提示されたViewControllerのpopoverPresentationControllerプロパティからそのインスタンスを取得し、それを使用してポップオーバーの動作を構成できます。

ビューコントローラを提示した直後にポップオーバーを設定したくない場合は、代わりにデリゲートオブジェクトを使用してポップオーバーを設定できます。プレゼンテーションプロセス中に、ポップオーバープレゼンテーションコントローラーは、デリゲートのさまざまなメソッド(UIPopoverPresentationControllerDelegateプロトコルに準拠するオブジェクト)を呼び出して、情報を要求し、プレゼンテーションの状態について通知します。デリゲートオブジェクトは、これらのメソッドを使用してポップオーバーを構成し、必要に応じてその動作を調整できます。ポップオーバープレゼンテーションコントローラのデリゲートを実装する方法については、UIPopoverPresentationControllerDelegateを参照してください。

ポップオーバープレゼンテーションコントローラを使用してビューコントローラを表示する方法については、「ポップオーバーでの一時的なコンテンツの表示」を参照してください。


var delegate: UIPopoverPresentationControllerDelegate?

ポップオーバー関連のメッセージを処理するデリゲート。

protocol UIPopoverPresentationControllerDelegate

UIPopoverPresentationControllerDelegateプロトコルのメソッドを使用すると、ポップオーバーベースのプレゼンテーションの動作をカスタマイズできます。 ポップオーバープレゼンテーションコントローラーは、プレゼンテーションプロセス中の適切な時点で代理人に通知します。 デリゲートメソッドを使用して、このプロセスをカスタマイズし、変更に動的に応答できます。

ポップオーバーの外観の構成

var popoverLayoutMargins: UIEdgeInsets
// The margins that define the portion of the screen in which it is permissible to display the popover.
var backgroundColor: UIColor?
// The color of the popover’s backdrop view.
var passthroughViews: [UIView]?
// An array of views that the user can interact with while the popover is visible.
var popoverBackgroundViewClass: UIPopoverBackgroundViewMethods.Type?
// The class to use for displaying the popover background content.
var canOverlapSourceViewRect: Bool
// ポップオーバーがビューの長方形に重なることができるかどうかを示すブール値。
// A Boolean value indicating whether the popover can overlap its view rectangle.
// このプロパティをtrueに設定すると、スペースが制限されているときに、
// ポップオーバーがsourceRectプロパティの長方形とオーバーラップするようになります。
// このプロパティのデフォルト値はfalseであり、ポップオーバーがソース長方形と
// オーバーラップするのを防ぎます。

ポップオーバーのアンカーポイントの指定

var barButtonItem: UIBarButtonItem?
// The bar button item on which to anchor the popover.
var sourceView: UIView?
// The view containing the anchor rectangle for the popover.
var sourceRect: CGRect
// ポップオーバーを固定する指定されたビューの長方形。
// The rectangle in the specified view in which to anchor the popover.
// このプロパティをsourceViewプロパティと組み合わせて使用して、
// ポップオーバーのアンカー位置を指定します。 
// または、barButtonItemプロパティを使用して、
// ポップオーバーのアンカー位置を指定することもできます。

ポップオーバー矢印の構成

var permittedArrowDirections: UIPopoverArrowDirection
// The arrow directions that you allow for the popover.
var arrowDirection: UIPopoverArrowDirection
// The arrow direction in use by the popover.
このスクラップは2021/05/09にクローズされました