0

Question: How does one implement (guess I mean by IOS best practice) a modal popover within a 'cocoa touch framework'?

Assumption here being it's a universal app so will support both iPhone and iPad. Could assume storyboard is being used for the main app that uses the cocoa touch framework.

For example, is best practice for the component to have to pass back a "please ask the user for info X,Y,Z to the main app and its view controller then use an approach like:

    let storyboard = UIStoryboard(name: "Main", bundle: nil)
    let controller = storyboard.instantiateViewController(withIdentifier: "EventPopover")
    controller.modalPresentationStyle = .popover
    self.present(controller, animated: true, completion: nil)

This would be difficult and then the app would need to be built a bit for the component (/framework) used, so this wouldn't seem possible? Alternative maybe to manually create a pop up view oneself within the component, however not sure whether you would benefit from an IOS best practice approach that would help support iPad and iPhone re the normal popover approach?

Example may be, say you have a custom map component you want the user to be able to drop in, but one aspect of the component is that when a user chooses/drops a pin you want to be able to throw up a modal dialog to ask the user to customise the name for this dropped pin.

(hope this makes sense)

Greg
  • 34,042
  • 79
  • 253
  • 454
  • i used this for popover: https://cocoapods.org/pods/Popover on iphone (since popover according to guidelines are meant for ipads). then just showing the xib inside the popover uiview. p.s. sorry if i'm not really answering your question cuz it sounds very complicated and not that clear. though i at least tried to answer.. – Tung Fam Jan 08 '17 at 11:54
  • @Tung thanks for responding – Greg Jan 08 '17 at 12:43

1 Answers1

0

I found using the UIViewController's popover mechanism is the approach, noting it will show a popover for iPad and for iPhone use the full screen.

   let storyboard = UIStoryboard(name: "Main", bundle: nil)
    let controller = storyboard.instantiateViewController(withIdentifier: "EventPopover")
    controller.modalPresentationStyle = .popover
    self.present(controller, animated: true, completion: nil)
Greg
  • 34,042
  • 79
  • 253
  • 454