UIPopOverPresentationController In Swift

UIPopOverPresentationController

UIPopOverViewController in swift is writen in swift 3.1 and Use the xcode Version 8.3.2.
For use this import the PopOverViewController folder into your project.
For using this file create the instance of PopOverViewC class and inherit the 

1
UIPopoverPresentationControllerDelegate

 :


1
  <span class="hljs-keyword">var</span> itemPopVC = <span class="hljs-type">PopOverViewC</span>()

Add below line of code in your Tapable button function for set the properties of UIPopOverViewController, change the properties


1
2
3
4
5
6
7
<span class="hljs-keyword">self</span>.itemPopVC.modalPresentationStyle = .popover
<span class="hljs-keyword">self</span>.itemPopVC.popoverPresentationController?.barButtonItem = <span class="hljs-keyword">self</span>.navigationItem.rightBarButtonItem
<span class="hljs-keyword">self</span>.itemPopVC.popoverPresentationController?.permittedArrowDirections = .unknown
<span class="hljs-keyword">self</span>.itemPopVC.popoverPresentationController?.delegate = <span class="hljs-keyword">self</span>
<span class="hljs-keyword">self</span>.itemPopVC.popoverPresentationController?.backgroundColor = <span class="hljs-type">UIColor</span>.red
<span class="hljs-keyword">self</span>.itemPopVC.popoverPresentationController?.popoverLayoutMargins = <span class="hljs-type">UIEdgeInsets</span>.<span class="hljs-keyword">init</span>(top: <span class="hljs-number">50.0</span>, <span class="hljs-keyword">left</span>: <span class="hljs-number">100.0</span>, bottom: <span class="hljs-number">0.0</span>, <span class="hljs-keyword">right</span>: <span class="hljs-number">0.0</span>)
<span class="hljs-keyword">self</span>.present(<span class="hljs-keyword">self</span>.itemPopVC, animated: <span class="hljs-literal">true</span>, completion: { <span class="hljs-number">_</span> <span class="hljs-keyword">in</span> })
1
self.itemPopVC.popoverPresentationController?.barButtonItem

 in this pass the tapable bar button, and there is 

1
sourceRect

 also in which
we pass the rect of any button.

For Get the didSelectCell call back add the notification and add these functions:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<span class="hljs-func"><span class="hljs-keyword">func</span> <span class="hljs-title">tableDidSelected</span><span class="hljs-params">(<span class="hljs-number">_</span> notification: Notification)</span></span>
  {
    <span class="hljs-keyword">var</span> indexpath: <span class="hljs-type">IndexPath</span>? = (notification.object <span class="hljs-keyword">as</span>? <span class="hljs-type">IndexPath</span>)
    <span class="hljs-keyword">self</span>.itemPopVC.dismiss(animated: <span class="hljs-literal">true</span>, completion: { <span class="hljs-number">_</span> <span class="hljs-keyword">in</span> })
  }
 
 
  <span class="hljs-func"><span class="hljs-keyword">func</span> <span class="hljs-title">popoverPresentationControllerShouldDismissPopover</span><span class="hljs-params">(<span class="hljs-number">_</span> popoverPresentationController: UIPopoverPresentationController)</span></span> -&gt; <span class="hljs-type">Bool</span>
  {
    <span class="hljs-keyword">return</span> <span class="hljs-literal">true</span>
  }
 
  <span class="hljs-func"><span class="hljs-keyword">func</span> <span class="hljs-title">adaptivePresentationStyle</span><span class="hljs-params">(<span class="hljs-keyword">for</span> controller: UIPresentationController)</span></span> -&gt; <span class="hljs-type">UIModalPresentationStyle</span>
  {
    <span class="hljs-keyword">return</span> <span class="hljs-type">UIModalPresentationStyle</span>.<span class="hljs-keyword">none</span>
  }

Related Post

Data Type And Storage And Keywords To store data inside the computer we need to first identify the type of data elements we need in our program. There are several different types of dat...
How to use Flutter most usable Widgets | Flutter t... We need some basic widgets for creating our first flutter app. Widgets describe what their view should look like given their current configuration and...
Java If-else Statement Java If-else Statement The Java if statement is used to test the condition. It checks boolean condition: true or false. For example, if a number i...
Drag and Drop Collection View cell in IOS 11 &... Drag and Drop Collection View cell in IOS 11 & swift 4 In this tutorial we are explain how to drag and drop collection view cell in two collectio...
Firebase Push notification | Swift tutorial Push Notification by firebase in IOS.For Firebase Push notification we need to have paid apple developer account. You need to Enroll into the Apple D...
C Language – Introduction Why C? There are three important aspects of any language so as C has : The way it stores data, The way it operates on this data and How th...

Leave a Reply

Your email address will not be published. Required fields are marked *