iOSアプリケーション用のNSPopoverに類似したものはありますか?これはMac用のオブジェクトライブラリには表示されますが、iPhoneやiPad用には表示されませんが、これを使用してアプリをダウンロードしています(または少なくとも非常に類似した機能)。iOS用NSPopover
私の質問:これを実装する正当な方法はありますか?
iOSアプリケーション用のNSPopoverに類似したものはありますか?これはMac用のオブジェクトライブラリには表示されますが、iPhoneやiPad用には表示されませんが、これを使用してアプリをダウンロードしています(または少なくとも非常に類似した機能)。iOS用NSPopover
私の質問:これを実装する正当な方法はありますか?
UIPopoverController
はあなたが探しているものです。
、相続人はチュートリアル
:これをグーグルでそれらの便宜上http://www.youtube.com/watch?v=1iykxemuxbk
は、UIPopoverController
はiPhoneとiPadの両方できるようになりましです。あなたは両方で同じように見えるpopoversを作ることができます(iOS 9のように、私は信じています)。
ステップ1:あなたのクラス定義にUIAdaptivePresentationControllerDelegate
とUIPopoverPresentationControllerDelegate
を含める
ステップ2:このようなあなたのクラスのどこかにプレゼンテーションをオーバーライド:
func adaptivePresentationStyle(for controller: UIPresentationController) -> UIModalPresentationStyle {
return .none
}
ステップ3:あなたをビューコントローラを提示すると、popover
スタイルを使用するように指示します。このような何か:
//I pull my popover from a separate storyboard, but any modal view will do
let storyboard = UIStoryboard(name: "Popovers", bundle: nil)
let modal = storyboard.instantiateViewController(withIdentifier: "AnyPickerModal") as! AnyPickerVC
modal.modalPresentationStyle = UIModalPresentationStyle.popover
let pc = modal.popoverPresentationController
pc?.permittedArrowDirections = .any
pc?.sourceView = <your button or view you tap to show the popover>
pc?.sourceRect = <your button or view>.bounds
//How big the popover should be
modal.preferredContentSize = CGSize(width: 300, height: 180)
pc?.delegate = self
self.present(modal, animated: true, completion: nil)
ご提示モーダルが両方 iPhoneやiPad上でポップオーバーとして表示されます。私のiPhoneアプリからのスクリーンショットが添付されています。コーディングハッピー
!
UIPopoverControllerはiPad専用です! –
したがって、プログラムで_popover_を作成する必要があります。 –