Start a Project

Pop up UIViewController on Click of UIButton in Swift 4 (POP UP Controller)

POP up UIViewController on Click of UIButton.

Some time we need to popup a controller on click of UIButton event not to cover all screen just cover some part of screen so we can show some message or perform some action on controller .

For this we need to follow some steps:

1: Take a Two UIViewController like that:

2: Here is “POP” is UIbutton , connect firstView Controller to another by Model Popover .

a: Select Button

b: go To “Connection Inspector”

c: In Triggered Section – select the action and connect to 2nd controller as “present as PopOver”

3: Now Its time to write the code in 1st viewcontroller.

a: Add the “UIPopoverPresentationControllerDelegate” in 1st UIViewcontroller class.

b: write their delegate method in 1st class.

It will look like as :

Here I have taken in 2nd Viewcontroller UItableview so you can can take any thing depends on your requirement.

You can also set the size of UITableView like that:

Here

I have taken custom width & Height if TableView .

Exit mobile version