Add 'Done' button to keyboard using UI Toolbar - swift

I have text views that I want to be able to have a done button. I have added a UI toolbar and connected it as an outlet plus IB action for the done button
The toolbar is not showing up? what have I missed?
func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool {
ingredientsTextField.inputAccessoryView
= keyboardToolbar
return true
}
#IBAction func didClickDoneButton(_ sender: UIBarButtonItem) {
ingredientsTextField.endEditing(true)
}

May be your creation of toolbar is wrong, check this
func textViewShouldBeginEditing(_ textView: UITextView) -> Bool {
self.addAccessoryView()
return true
}
func addAccessoryView() -> Void {
let toolBar = UIToolbar(frame: CGRect(x: 0, y: 0, width: self.view.frame.size.width, height: 44))
let doneButton = UIBarButtonItem(title: "Done", style: .done, target: self, action: #selector(self.doneButtonTapped(button:)))
let flexibleSpace = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil)
toolBar.items = [flexibleSpace,doneButton]
toolBar.tintColor = UIColor.red
self.textView.inputAccessoryView = toolBar
}
func doneButtonTapped(button:UIBarButtonItem) -> Void {
// do you stuff with done here
}

Your code snippet looks fine! Did you set the delegate for your textfield? If you missed it please set it else func textFieldShouldBeginEditing will not be called!
Please find below working code for your reference,
import UIKit
class ViewController: UIViewController,UITextFieldDelegate {
#IBOutlet weak var textField: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
internal func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool {
let numberToolbar = UIToolbar(frame: CGRect(x: 0, y: 0, width: self.view.frame.size.width, height: 50))
numberToolbar.barStyle = UIBarStyle.default
numberToolbar.items = [
UIBarButtonItem(title: "Cancel", style: UIBarButtonItemStyle.plain, target: self, action: Selector(("cancelNumberPad"))),
UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.flexibleSpace, target: nil, action: nil),
UIBarButtonItem(title: "Done", style: UIBarButtonItemStyle.plain, target: self, action: Selector(("doneWithNumberPad")))]
numberToolbar.sizeToFit()
textField.inputAccessoryView
= numberToolbar
return true
}
#IBAction func didClickDoneButton(_ sender: UIBarButtonItem) {
textField.endEditing(true)
}
#IBAction func buttonClick(_ sender: Any) {
textField.endEditing(true)
}
}

Related

InputAccessoryView and my problem (Swift)

I have such screen:
When you click on a textfield, the top of the keyboard should have "two arrows" on the left and the button "Done" on the right.
Like this:
I must say right away that I used Iqkeyboardmanager and because of this library there were problems therefore I had to remove it from the project. So help do it manually.
In the project, I already implemented the Done button, my code:
extension UITextField {
func addInputAccessoryView(title: String, target: Any, selector: Selector) {
let toolBar = UIToolbar(frame: CGRect(x: 0.0,
y: 0.0,
width: UIScreen.main.bounds.size.width,
height: 44.0))
let flexible = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil)
let barButton = UIBarButtonItem(title: title, style: .plain, target: target, action: selector)
toolBar.setItems([flexible, barButton], animated: false)
self.inputAccessoryView = toolBar
}
}
final class ProfileSettingsViewController: UIViewController,UINavigationControllerDelegate, UIImagePickerControllerDelegate, UITextFieldDelegate {
#objc func tapDone() {
self.view.endEditing(true)
}
override func viewDidLoad() {
super.viewDidLoad()
self.nameTF.addInputAccessoryView(title: "Done", target: self, selector: #selector(tapDone))
self.companyTF.addInputAccessoryView(title: "Done", target: self, selector: #selector(tapDone))
self.nameTF.delegate = self
self.companyTF.delegate = self
.....
The rest of the code
}
}
What i have at the moment:
I need to add two black arrows on the left and make the Done buttons black. Help me please.
If you think my code is bad, you can provide your correct example. I am new in ios development.
1.Create a custom delegate which will notify the ViewController when some button is pressed inside the Input Accessory View.
protocol MyCustomTextFieldDelegate: class {
func doneButtonPressed()
func arrowDownPressed()
func arrowUpPressed()
}
2.Create a custom subclass of the the UITextField and make a function that will create the Input Accessory View. Define the newly created MyCustomTextFieldDelegate as a weak class property. (Note: we are making this subclass, as we are unable to add the MyCustomTextFieldDelegate as a property to the UITextField directly)
class MyCustomTextField: UITextField {
weak var customTextFieldDelegate: MyCustomTextFieldDelegate?
func enableInputAccessoryView() {
let toolBar = UIToolbar(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 50))
toolBar.barStyle = UIBarStyle.default
toolBar.isTranslucent = true
let space = UIBarButtonItem(barButtonSystemItem: UIBarButtonItem.SystemItem.flexibleSpace, target: nil, action: nil)
let doneButton = UIBarButtonItem(title: "Done", style: .done, target: self,
action: #selector(textFieldDonePressed))
doneButton.tintColor = .black
let arrowDown = UIBarButtonItem(image: UIImage(named: "arrow-right"), style: .done, target: self, action: #selector(arrowUpPressed))
arrowDown.tintColor = .black
let arrowUp = UIBarButtonItem(image: UIImage(named: "arrow-right"), style: .done, target: self, action: #selector(arrowDownPressed))
arrowUp.tintColor = .black
toolBar.setItems([arrowUp, arrowDown, space, doneButton], animated: false)
toolBar.isUserInteractionEnabled = true
toolBar.sizeToFit()
inputAccessoryView = toolBar
}
#objc private func textFieldDonePressed() {
endEditing(true)
customTextFieldDelegate?.doneButtonPressed()
}
#objc private func arrowDownPressed() {
customTextFieldDelegate?.arrowDownPressed()
}
#objc private func arrowUpPressed() {
customTextFieldDelegate?.arrowUpPressed()
}
}
3.In your ViewController change your current UITextField to your new MyCustomTextField and apply the Input Accessory View.
yourTextField.enableInputAccessoryView()
4.Set your ViewController to be the MyCustomTextField delegate.
yourTextField.customTextFieldDelegate = self
5.Confrom your ViewController to the newly created MyCustomTextFieldDelegate, where you will handle the user interaction.
extension YourViewController: MyCustomTextFieldDelegate {
func doneButtonPressed() {
// Handle done Pressed
}
func arrowDownPressed() {
// Handle down pressed
}
func arrowUpPressed() {
// Handle up pressed
}
}

xcode navigation bar button state

I have an edit button - UIBarButtonItem
which disappears from screen when it was clicked
and appears when cancel button was clicked
As you can see, the state of edit button stays selected after appearing.
How can I programmatically change Navigation bar buttons state to normal state? Or suggest me a better way.
here is my project code
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource, introductionDelegate {
var navBarEditButton: UIBarButtonItem?
var navBarDeleteButton: UIBarButtonItem?
var navBarCancelButton: UIBarButtonItem?
override func viewDidLoad() {
super.viewDidLoad()
self.navBarEditButton = UIBarButtonItem(title: "Edit", style: .plain, target: self, action: #selector(editObjectsAction))
self.navBarDeleteButton = UIBarButtonItem(title: "Delete", style: .plain, target: self, action: #selector(deleteObjectsAction))
self.navBarCancelButton = UIBarButtonItem(title: "Cancel", style: .plain, target: self, action: #selector(cancelAction))
self.navigationItem.leftBarButtonItems = [navBarEditButton!]
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
#objc private func editObjectsAction(_ sender: UIBarButtonItem) {
self.navigationItem.leftBarButtonItems = [navBarCancelButton!, navBarDeleteButton!]
}
#objc private func cancelAction(_ sender: UIBarButtonItem) {
self.navigationItem.leftBarButtonItems = [navBarEditButton!]
}
#objc private func deleteObjectsAction(_ sender: UIBarButtonItem) {
}
you can create UIBarButtonItem with UIButton and handle the state on that button. With this, you change the UIBarButtonItem style but just check whether you get the intended result.
let myButton = UIButton(frame: CGRect(x: 10, y: 300, width: 100, height: 40)) // handle state on this button
self.navBarEditButton = UIBarButtonItem(customView: myButton)
I have added a new function
func refreshNavBarButton (navBarButton: inout UIBarButtonItem) {
navBarButton = UIBarButtonItem(title: navBarButton.title, style: navBarButton.style, target: navBarButton.target, action: navBarButton.action)
}
And I call it every time before navigation bar button showing
refreshNavBarButton(navBarButton: &navBarEditButton!)
self.navigationItem.leftBarButtonItems = [navBarEditButton!]

Can't dismiss KeyBoard when a Done button pressed in UITableViewCell

First, done button codes are below
class ViewController: UIViewController, UITextFieldDelegate {
let inputNumber = UITextField(frame: CGRect(x: 150.0, y: 100.0, width: 200.0, height: 50.0))
let toolBarKeyBoard = UIToolbar()
let flexibleSpace = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil)
let doneButton = UIBarButtonItem(barButtonSystemItem: .done, target: nil, action: #selector(donePressed))
var result : String!
override func viewDidLoad() {
super.viewDidLoad()
calculatePrice()
}
func calculatePrice () {
priceInputLabel.keyboardType = .numberPad
priceInputLabel.clearButtonMode = .whileEditing
self.view.addSubview(priceInputLabel)
toolBarKeyBoard.sizeToFit()
toolBarKeyBoard.setItems([flexibleSpace, doneButton], animated: false)
priceInputLabel.inputAccessoryView = toolBarKeyBoard
}
#objc func donePressed() {
view.endEditing(true)
}
}
It works OK. When I touch 'inputNumber(UITextField)', a keyboard pops up. And when I input Number and touch 'Done' button, a keyboard dismisses. Good.
But, in other codes, down below, doesn't work.
class FruitTableViewCell: UITableViewCell, UITextFieldDelegate {
var fruitsTextField = UITextField()
let toolBarKeyBoard = UIToolbar()
let flexibleSpace = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil)
let doneButton = UIBarButtonItem(barButtonSystemItem: .done, target: nil, action: #selector(donePressed))
var result : String!
override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
self.contentView.addSubview(fruitsTextField)
}
override func layoutSubviews() {
super.layoutSubviews()
fruitsTextField.frame = CGRect(x: 250, y: 7.5, width: 100, height: 30)
fruitsTextField.textColor = UIColor(red: CGFloat(242/255.0), green: CGFloat(56/255.0), blue: CGFloat(90/255.0), alpha: 1.0)
fruitsTextField.keyboardType = .numberPad
fruitsTextField.clearButtonMode = .whileEditing
toolBarKeyBoard.sizeToFit()
fruitsTextField.inputAccessoryView = toolBarKeyBoard
toolBarKeyBoard.setItems([flexibleSpace, doneButton], animated: false)
}
#objc func donePressed() {
fruitTextField.endEditing(true)
}
I can build, I can toggle a keyboard, I can touch a done button, but it doesn't dismiss a keyboard.
I think, the function '#objc func donePressed()' at the bottom line is matter.
First codes are 'view.endEditing(true)' but these are 'fruitTextField.endEditing(true)'
So, I tried to change codes.
#objc func donePressed() {
contentView.endEditing(true)
}
But doesn't work.
Question1. How can I dismiss a keyboard?
Question2. Why doesn't a keyboard dismiss even though I touched 'Done' button?
Question3. In second code, is a keyboard not the FirstResponder?
Question4. In second code, what is the View for '.endEditing'?
Thanks!
Change your "done button" initialization to:
lazy var doneButton = UIBarButtonItem(barButtonSystemItem: .done, target: self, action: #selector(donePressed))
You need target: self, and you need it to be lazy in order for self to be valid when the button is instantiated.
You can also change your done func to:
#objc func donePressed() {
fruitsTextField.resignFirstResponder()
}
Doesn't really change the functionality, but I believe it is the recommended method.

Add action to UIBarButtonItem dynamically Swift 4

let doneButton = UIBarButtonItem(title: "Done", style: UIBarButtonItemStyle.plain, target: self, action: #selector(buttonClicked(sender:)))
#objc func buttonClicked(sender: UIBarButtonItem) {
print("Hello")
}
That's the code for my UIBarButton but when I click on it it doesn't print "Hello", what could be the problem?
EDIT: Here are my viewcontroller
It simply control a button that when it's clicked show the spinner with its control, but as I said before the button on toolbar doesn't work
class FilterViewController: UIViewController {
var search: Search?
let categoriesSpinnerDelegate = CategoriesPickerDelegate()
#IBOutlet weak var generalSpinner: UIPickerView!
#IBOutlet weak var categoriesButton: UIButton!
#IBOutlet weak var categoryRow: UIView!
var doneButton: UIBarButtonItem?
override func viewDidLoad() {
super.viewDidLoad()
self.navigationController?.topViewController?.title = "Filtri"
// Set border and click action
self.categoryRow.layer.borderWidth = 1
self.categoryRow.layer.borderColor = Raccoltacase.lightGray.cgColor
self.categoryRow.addGestureRecognizer(UIPanGestureRecognizer(target: self, action: #selector(self.buttonClicked(sender:))))
// Create toolbar and attach it to pickerView
let toolBar = UIToolbar()
toolBar.barStyle = UIBarStyle.default
toolBar.isTranslucent = true
//toolBar.tintColor = UIColor(red: 76/255, green: 217/255, blue: 100/255, alpha: 1)
toolBar.sizeToFit()
self.doneButton = UIBarButtonItem(title: "Done", style: UIBarButtonItemStyle.plain, target: self, action: #selector(buttonClicked(sender:)))
let spaceButton = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.flexibleSpace, target: nil, action: nil)
let cancelButton = UIBarButtonItem(title: "Cancel", style: UIBarButtonItemStyle.plain, target: self, action: nil)
toolBar.setItems([cancelButton, spaceButton, doneButton!], animated: false)
toolBar.isUserInteractionEnabled = true
generalSpinner.addSubview(toolBar)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
#IBAction func categoriesButtonClick(_ sender: UIButton) {
self.generalSpinner.showsSelectionIndicator = true
self.generalSpinner.dataSource = categoriesSpinnerDelegate
self.generalSpinner.delegate = categoriesSpinnerDelegate
self.generalSpinner.isHidden = false
}
#objc func buttonClicked(sender: UIBarButtonItem) {
print("Hello")
}
}
Screen
Assuming that you are showing the picker sometimes (and dismissing it when user presses the done button), here is my solution:
Add a UITextField to the view in storyboard (and make the tintColor transparent (clearColor))
Add the UIToolbar as inputAccessoryView to the UITextField
Add the UIPickerView as inputView to the toolbar (Also see the note below)
Below is a sample code:
override func viewDidLoad() {
super.viewDidLoad()
textField.inputView = generalSpinner
textField.inputAccessoryView = getToolbar()
}
func getToolbar() -> UIToolbar {
let toolBar = UIToolbar(frame: CGRect(x: 0, y: 0, width: self.view.frame.width, height: 40))
toolBar.barStyle = UIBarStyle.default
toolBar.isTranslucent = true
self.doneButton = UIBarButtonItem(title: "Done", style: UIBarButtonItemStyle.plain, target: self, action: #selector(buttonClicked(sender:)))
let spaceButton = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.flexibleSpace, target: nil, action: nil)
let cancelButton = UIBarButtonItem(title: "Cancel", style: UIBarButtonItemStyle.plain, target: self, action: nil)
toolBar.setItems([cancelButton, spaceButton, doneButton!], animated: false)
toolBar.isUserInteractionEnabled = true
return toolBar
}
Note: In case the UIPickerView is already in the storyboard (or a subview of another view), make sure to remove it in the first line of viewDidLoad (as shown below):
override func viewDidLoad() {
super.viewDidLoad()
generalSpinner.removeFromSuperview()
textField.inputView = generalSpinner
textField.inputAccessoryView = getToolbar()
}
SOLVED
When i use pickerView.addSubView(toolbar) the toolbar was placed behind the pickerview and so it was no clickable. I solved it adding the toolbar manually from storyboard with General Spinner.top = Picker Toolbar.bottom

Creating Sign Up View page in SWIFT with A UIImage profile picture setup, Using NEXT as Return Key and UIImage setup not working

I am building an app with which my focus is on User Friendly.
In the SignUpViewController, i have a profilePic of type UIImage, Four standard UITextFields to record user's data, and Two more UITextField which activates a UIDatePicker and a UIPicker.
I'm experiencing some problems such as;
1) The UIImage doesn't clip to bounds to give it the round sort of look
2) When i use the UIImage to fetch image from my gallery, it doesn't give me the option to scale my image size and rather gives me a static image pick
3) My UITextFields don't respond to the Next settings i have used. Again, the next setting has been implemented in my LogInViewController and works perfectly. But why isn't it working in the SignUpViewController?
A big thank you in advance.
import UIKit
import Parse
class SignUpViewController: UIViewController, UITextFieldDelegate, UIPickerViewDataSource, UIPickerViewDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
#IBOutlet weak var profilePic: UIImageView!
#IBOutlet weak var firstName: UITextField!
#IBOutlet weak var lastName: UITextField!
#IBOutlet weak var signUpEmail: UITextField!
#IBOutlet weak var signUpPassword: UITextField!
#IBOutlet weak var dateTextField: UITextField!
#IBOutlet weak var genderTextField: UITextField!
var datePicker:UIDatePicker!
var genderPicker:UIPickerView!
var genderSelect = ["Male", "Female"]
override func viewDidLoad() {
super.viewDidLoad()
// PROFILE PICTURE
let tapGesture = UITapGestureRecognizer(target: self, action: "imageTapped:")
profilePic.addGestureRecognizer(tapGesture)
profilePic.userInteractionEnabled = true
profilePic.frame = CGRect(x: 10, y: 170, width: 80, height: 80)
profilePic.layer.cornerRadius = profilePic.frame.size.width / 2
profilePic.clipsToBounds = true
// UI DATE PICKER SETUP
var customView:UIView = UIView(frame: CGRectMake(0, 100, 320, 160))
customView.backgroundColor = UIColor.clearColor()
datePicker = UIDatePicker(frame: CGRectMake(0, 0, 320, 160))
datePicker.datePickerMode = UIDatePickerMode.Date
datePicker.maximumDate = NSCalendar.currentCalendar().dateByAddingUnit(.CalendarUnitYear, value: -16, toDate: NSDate(), options: nil)
customView.addSubview(datePicker)
dateTextField.inputView = customView
var dateToolBar = UIToolbar()
dateToolBar.barStyle = UIBarStyle.Default
dateToolBar.translucent = true
dateToolBar.tintColor = UIColor(red: 246/255, green: 141/255, blue: 17/255, alpha: 1)
dateToolBar.sizeToFit()
dateTextField.inputAccessoryView = dateToolBar
var doneButton = UIBarButtonItem(title: "Done", style: UIBarButtonItemStyle.Plain, target: self, action: "datePickerSelected")
var spaceButton = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.FlexibleSpace, target: nil, action: nil)
var cancelButton = UIBarButtonItem(title: "Cancel", style: UIBarButtonItemStyle.Plain, target: self, action: "cancelPicker")
dateToolBar.setItems([cancelButton, spaceButton, doneButton], animated: true)
dateToolBar.userInteractionEnabled = true
// UI GENDER PICKER VIEW
genderPicker = UIPickerView(frame: CGRectMake(0, 0, 320, 160))
genderPicker.showsSelectionIndicator = true
var customGenderView:UIView = UIView(frame: CGRectMake(0, 100, 320, 160))
customGenderView.backgroundColor = UIColor.clearColor()
customGenderView.addSubview(genderPicker)
genderTextField.inputView = customGenderView
var toolBar = UIToolbar()
toolBar.barStyle = UIBarStyle.Default
toolBar.translucent = true
toolBar.tintColor = UIColor(red: 246/255, green: 141/255, blue: 17/255, alpha: 1)
toolBar.sizeToFit()
genderPicker.delegate = self
genderPicker.dataSource = self
var doneBtn = UIBarButtonItem(title: "Done", style: UIBarButtonItemStyle.Plain, target: self, action: "donePicker")
var spaceBtn = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.FlexibleSpace, target: nil, action: nil)
var cancelBtn = UIBarButtonItem(title: "Cancel", style: UIBarButtonItemStyle.Plain, target: self, action: "cancelPicker")
toolBar.setItems([cancelBtn, spaceBtn, doneBtn], animated: true)
toolBar.userInteractionEnabled = true
genderTextField.inputView = genderPicker
genderTextField.inputAccessoryView = toolBar
}
func textFieldShouldReturn(textField: UITextField) -> Bool {
if let nextField = textField.nextField {
nextField.becomeFirstResponder()
}
return true
}
// UIIMAGE TO FUNCTION AS BUTTON WHEN TAPPED
func imageTapped(gesture:UIGestureRecognizer) {
if let profilePic = gesture.view as? UIImageView {
showActionSheet()
}
}
func camera() {
var myPickerController = UIImagePickerController()
myPickerController.delegate = self
myPickerController.sourceType = UIImagePickerControllerSourceType.Camera
//myPickerController.allowsEditing = true
self.presentViewController(myPickerController, animated: true, completion: nil)
}
func photoLibrary()
{
var myPickerController = UIImagePickerController()
myPickerController.delegate = self
myPickerController.sourceType = UIImagePickerControllerSourceType.PhotoLibrary
myPickerController.allowsEditing = true
//myPickerController.setEditing(true, animated: true)
self.presentViewController(myPickerController, animated: true, completion: nil)
}
func showActionSheet() {
let actionSheet = UIAlertController(title: nil, message: nil, preferredStyle: UIAlertControllerStyle.ActionSheet)
actionSheet.addAction(UIAlertAction(title: "Camera", style: UIAlertActionStyle.Default, handler: { (alert:UIAlertAction!) -> Void in
self.camera()
}))
actionSheet.addAction(UIAlertAction(title: "Gallery", style: UIAlertActionStyle.Default, handler: { (alert:UIAlertAction!) -> Void in
self.photoLibrary()
}))
actionSheet.addAction(UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Cancel, handler: nil))
self.presentViewController(actionSheet, animated: true, completion: nil)
}
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [NSObject: AnyObject]) {
profilePic.image = info[UIImagePickerControllerOriginalImage] as? UIImage
self.dismissViewControllerAnimated(true, completion: nil)
}
// DATE FORMATTING AND CHOOSING
func datePickerSelected() {
dateTextField.text = datePicker.date.description
dateTextField.text = self.dateformatterDate(datePicker.date) as String
dateTextField.resignFirstResponder()
}
func dateformatterDate(date: NSDate) ->NSString {
var dateFormatter: NSDateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "dd/MM/yyyy"
return dateFormatter.stringFromDate(date)
}
// GENDER SELECT
func numberOfComponentsInPickerView(pickerView: UIPickerView) -> Int {
return 1
}
func pickerView(pickerView:UIPickerView, numberOfRowsInComponent component: Int) ->Int {
return genderSelect.count
}
func pickerView(pickerView:UIPickerView, titleForRow row:Int, forComponent component:Int) -> String! {
return genderSelect[row]
}
func pickerView(pickerView:UIPickerView, didSelectRow row:Int, inComponent component:Int) {
genderTextField.text = genderSelect[row]
}
func textFieldShouldBeginEditing(textField: UITextField) -> Bool {
return false
}
func genderPickerSelected() {
genderTextField.text = genderPicker.description
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
self.view.endEditing(true)
}
#IBAction func signUpBtn(sender: AnyObject) {
}
}
1.
Tell the imageView to clip to bounds after image assignment. I also suggest altering it's content mode accordingly if desired (aspect fill, fit, etc.)
Edit: Also reset the corner radius.
You need to scale images yourself in your didFinishPickingMediaWithInfo method. There are lots of different ways to do this, about halfway down this page is one I used a few times: http://www.raywenderlich.com/93276/implementing-tesseract-ocr-ios
Did you set the textFieldNameHere.delegate = self anywhere? I couldn't spot it.