logo
down
shadow

Multiple separate Pickerviews in Swift


Multiple separate Pickerviews in Swift

By : user2950008
Date : November 17 2020, 04:28 AM
Any of those help I am new to programming, so please forgive the basic nature of this question. , For displaying two components you need to change your methods like:
code :
func numberOfComponentsInPickerView(pickerView: UIPickerView!) ->Int
{
       return 2
}


func pickerView(pickerView: UIPickerView!, numberOfRowsInComponent component: Int) ->Int
{
    var rows = var2.count
    if component == 0
    {
        rows = var1.count
    }
    return rows;
}


func pickerView(pickerView: UIPickerView!, titleForRow row: Int, forComponent component: Int)->String!
{
    var componentStr = var2[row]
    if component == 0
    {
        componentStr = var1[row]
    }
    return componentStr;
}


Share : facebook icon twitter icon
Multiple pickerviews with multiple textfield inputviews Swift

Multiple pickerviews with multiple textfield inputviews Swift


By : user2608165
Date : March 29 2020, 07:55 AM
With these it helps You're using the picker views' tag property to decide which array is the data source for a given picker view, but you didn't set the tags initially. The tag defaults to zero, so all four picker views are showing the same data. After instantiating your picker views, add this:
code :
pickerView1.tag = 0
pickerView2.tag = 1
pickerView3.tag = 2
pickerView4.tag = 3
Swift PickerViews issue

Swift PickerViews issue


By : Vladimir Kucbel
Date : November 07 2020, 09:00 AM
hop of those help? The problem is your textFieldShouldBeginEditing method. You are just setting the .hidden property for one of the pickerViews. Add tags to both of your textFields (like 2 and 3) and change the method to this:
code :
func textFieldShouldBeginEditing(textField: UITextField) -> Bool {
    if textField.tag == 2 {
        pickerpeso.hidden = false
        pickerpeso2.hidden = true
    } else if textField.tag == 3 {
        pickerpeso.hidden = true
        pickerpeso2.hidden = false
    }
    return false
}
Use of unresolved identifier, recognizing 2 different pickerViews containing the same information. In Swift

Use of unresolved identifier, recognizing 2 different pickerViews containing the same information. In Swift


By : Alexndar Jenny
Date : March 29 2020, 07:55 AM
wish helps you I am farely new at proggraming and I am trying to build an app, but I cant figure out how to fix my problem. All the help is gladly appreciated!!!! , If you create @IBOutlets to your two pickerViews:
code :
@IBOutlet weak var picker1: UIPickerView!
@IBOutlet weak var picker2: UIPickerView!
let row1 = picker1.selectedRow(inComponent: 0)
let row2 = picker2.selectedRow(inComponent: 0)
class ViewController: UIViewController, UIPickerViewDelegate, UIPickerViewDataSource {

    @IBOutlet weak var picker1: UIPickerView!
    @IBOutlet weak var picker2: UIPickerView!

    var data = [1, 2, 3, 4, 5]

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

    func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
        let sum = data[picker1.selectedRow(inComponent: 0)] + data[picker2.selectedRow(inComponent: 0)]
        print(sum)
    }

    func numberOfComponents(in pickerView: UIPickerView) -> Int {
        return 1
    }

    func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
        return data.count
    }

    func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
        return String(data[row])
    }
}
How to create Custom UI Date PickerViews in the same UIView in swift

How to create Custom UI Date PickerViews in the same UIView in swift


By : adservio
Date : March 29 2020, 07:55 AM
it fixes the issue Im trying to have two different date pickerViews on the same viewController and let them represent different data. I have tried a different ways to do this, but both date picker views showing same Data, but can't put it all together.I'm new to swift programming. Any help would be awesome!
code :
@IBOutlet weak var EventStart: UITextField!
var datepicker = UIDatePicker()
var datepicker2 = UIDatePicker()
@IBOutlet weak var EventEnd: UITextField!

override func viewDidLoad() {
    super.viewDidLoad()

   self.addDatePicker(datepicker, textfield:EventStart , selector: #selector(ViewController.donePressed))
    self.addDatePicker(datepicker2 , textfield:EventEnd ,selector: #selector(ViewController.donePressed2))

    // Do any additional setup after loading the view.
}


func addDatePicker(_ datepicker : UIDatePicker, textfield: UITextField, selector: Selector) {


    let toolbar = UIToolbar()
    toolbar.sizeToFit()
    let doneButton = UIBarButtonItem(barButtonSystemItem: .done, target: nil, action:selector)
    toolbar.setItems([doneButton], animated: false)


    textfield.inputAccessoryView = toolbar
    textfield.inputView = datepicker

}

func donePressed(){
    let dateFormatter = DateFormatter()
    dateFormatter.dateStyle = .medium
    dateFormatter.timeStyle = .none
    EventStart.text = dateFormatter.string(from: datepicker.date)
    print(EventStart)
    self.view.endEditing(true)
}

func donePressed2(){
    let dateFormatter = DateFormatter()
    dateFormatter.dateStyle = .medium
    dateFormatter.timeStyle = .none
    EventEnd.text = dateFormatter.string(from: datepicker2.date)
    print(EventEnd)
    self.view.endEditing(true)
}
I see only ?-s when using 2 pickerviews in Swift on the same view controller, how to fix this?

I see only ?-s when using 2 pickerviews in Swift on the same view controller, how to fix this?


By : programsandcodes
Date : March 29 2020, 07:55 AM
To fix this issue I have been trying to figure out this problem for hours, now I have only one small problem remaining: , You need this signature ( missed _ )
code :
func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String! {
Related Posts Related Posts :
  • Axis change of stackView giving layout error
  • How to use AVAssetResourceLoader?
  • How to write block definition using properties?
  • iOS connect/reconnect to Bluetooth device when using external-accessory and MFi
  • Saving XMPP Multi User chat messages through XMPP MessageArchiving in iOS
  • Deciding iOS version: pros and cons
  • iOS: Resigned app cannot access keychain through security API
  • How can I set To and Subject fields in an E-Mail being sent by UIDocumentInteractionController?
  • Updating uilabel in view controller underneath another
  • Maximum time Intervel for NSTimer
  • Delete Core Data Entry from Table View Controller
  • How to unload UIViewcontroller from memory?
  • Compressing UIImage as Far as Possible?
  • Optimizing workflow to update internally owned cocoapods dependencies?
  • Formatting an NSDate with Abbreviated Month/Day Names
  • I'm creating a quiz game with 4 answers and I want to add score
  • Tap Gesture to Hide Navigation Bar, Tab Bar, and Status Bar
  • FBSessionStateClosedLoginFailed when I am logged in through Settings
  • CGRect positioning according to center point
  • iOS: Update table view datasource with animations without core data
  • iOS : Where to start for AliPay integration?
  • Routing App Coverage File missing but not needed?
  • Drawing on a zoomable view
  • Append NSStrings and NSNumber to NSMutableArrays and make NSMutable dictionary
  • Terminating app due to uncaught exception 'NSRangeException' when calling dequeueReusableCellWithReuseIdentifier:forInde
  • Collision without physics (Cocos2D + Box2D iOS)
  • Creating a percentage based iOS layout
  • Update tableView row from AppDelegate Swift 4
  • Assigning return value of a class method to a variable error
  • how to display circular progress in delphi ios apps?
  • I can't figure how to fix this Expected identifier or '('
  • How to Test APIs in Swift 4?
  • Link error /Build/Products/Debug-iphonesimulator file not found
  • working with a very large JSON object in iOS
  • Turn off part of the iPhone Screen
  • Phonegap 3.0 app with facebook login using xCode
  • How to add interstitial admob ads to my ios project
  • adding tapku calendar to ios app
  • Add an alertcontroller in a global swift file?
  • Take square image with Cordova (Phonegap) Camera API?
  • Amazon S3 policy allowing only upload not overwrite
  • How to change the UILabel content by tapping?
  • Adding checkmark to selected table cell also checks another table cell
  • UICollectionView cellForItemAtIndexPath indexPath row is nil
  • Resize and set quality on JPEG image while retaining EXIF in iOS
  • How to push rootviewcontroller in Ios
  • How to add UIBarbuttonItem at centre on UInavigationbar in iOS
  • Would this IOS device test crash be expected
  • PickerView not showing any values
  • How to set root view controller in storyboard animated with navigation controller programmatically
  • Can anyone suggest me the effective way to deal with s3 upload fail because of timezone difference issue?
  • Getting list of files in documents folder
  • Error while using Realm Object as a singleton. Is it a good idea?
  • inserting into SQLite database
  • More nodes than I should
  • Facebook IOS SDK navigate to another controller after login not working
  • Swift Array - use "Contains" of type AnyObject
  • Sidebar menu with indicate navigationbar on iOS
  • Programmatically set size of UIView from Storyboard
  • Navigation bar blink
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org