Advertisement
Guest User

Untitled

a guest
Sep 17th, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 1.16 KB | None | 0 0
  1. import UIKit
  2.  
  3. class ViewController: UIViewController, UIPickerViewDataSource, UIPickerViewDelegate {
  4.    
  5.  
  6.     @IBOutlet weak var pickerView: UIPickerView!
  7.    
  8.    
  9.      let currencyArray = ["AUD", "BRL","CAD","CNY","EUR","GBP","HKD","IDR","ILS","INR","JPY","MXN","NOK","NZD","PLN","RON","RUB","SEK","SGD","USD","ZAR"]
  10.  
  11.     override func viewDidLoad() {
  12.         super.viewDidLoad()
  13.        
  14.         pickerView.dataSource=self
  15.         pickerView.delegate=self
  16.  
  17.     }
  18.  
  19.  
  20.     /* total picker view row */
  21.     func numberOfComponents(in pickerView: UIPickerView) -> Int {
  22.         return 1
  23.     }
  24.    
  25.    
  26.     /* total row count*/
  27.     func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
  28.         return currencyArray.count
  29.     }
  30.    
  31.     /* show row view */
  32.       func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
  33.         return currencyArray[row]
  34.     }
  35.    
  36.     /* when click row get index data */
  37.     func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
  38.         print(currencyArray[row])
  39.     }
  40.    
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement