Is there a way to implement a "swipe to remove" action on UIPickerView, just like it's done with UITableViewController?
I've been searching for this for some time, but have no solution.
UIPickerView objects are not editable. When in doubt, check the documentation: http://developer.apple.com/library/ios/#documentation/uikit/reference/UIPickerView_Class/Reference/UIPickerView.html
However, there's no reason why you couldn't make a custom UIPickerView using a UITableViewController and a bit of clever code to figure out which cell is in the middle and properly highlight it.
Related
Goal
I want to have a keyboard (custom) to show when I click on a cell in my tableview and have said keyboard edit a label in the selected cell.
What I have read and tried
Stack overflow and other searched threads/tutorials
A Swift example of Custom Views for Data Input (custom in-app keyboard)
How to make custom keyboard only for my app in Swift?
iOS 8: Creating a Custom Keyboard in Swift
Along with other results and searches (also the recommended readings within these threads), these were great for me getting the keyboard the way I want it (which is app-specific, I don't want to have the user install the keyboard to use the app), however, none explain how I could "activate" the keyboard without a textfield.
My thought process is this: I will have a keyboard with a textfield in place in order to receive the input from the keys pressed. This input would then be sent to the label that is in the selected cell. The problem is in the keyboard showing without anything to call it...
Why I don't want a textfield in the cell: Because I think it is more smart/elegant to have the tableview cell activate the keyboard. I have seen this in other apps and I can't figure out how it is done.
Any help on this matter is much appreciated. I am completely new to programming, am using Swift (so have no clue Obj-C or the like).
Thank you!
Well after a lot of discussions around other websites, it is a shame to say it but what I wanted was actually impossible (like stated by Duncan). For some reason I thought that in programming that word did not exist, but alas it is there. Well, the way that I did work around this limitation was as replied here in the comments as well as from the resource materials I already read:
I have 2 views:
tableView - this will have the list of items that I would like to edit a value. Has multiple labels where one of them would be edited by the user.
keyboardView - custom keyboard that would allow user input.
For the keyboard I used the delegate method as described in "A Swift example of Custom Views for Data Input". This worked perfectly and would send the data over to the tableView under the keyWasTapped function.
Next was the tableView. I had 3 labels in the custom cell, where one was called valueLabel. I had to add a textField to my storyboard hidden behind the tableview with which the user will interact and in the didselectrow I included the command to summon the keyboard:
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
textField.becomeFirstResponder()
}
From there I would grab the text from the textfield and update the UILabels in my custom cell. At least this way I can select a cell and not the textfield. So considering that the answer that would fit what I wanted is combination of the replies, I thought it would be best to say it here.
Thanks to Sandeep and Larme for their time.
TVDN,
Have a textField in cell not the label :) Create a custom cell create an IBOutlet to that class ffrom textField in cellForRowAtIndexPath
let tableCell = self.tableView.dequeueReusableCellWithIdentifier("cell") as! myCell
tableCell.yourTextField.resignFirstResponder()
and in didSelectRowAtIndexPath
let tableCell = self.tableView.cellForRowAtIndexPath(indexPath)
self.tableView.dequeueReusableCellWithIdentifier("cell") as! myCell
tableCell.yourTextField.becomeFirstResponder()
I have three cells in my tableview which is standard tableview not custom cell. However, I would like the last cell to be editable, in other words I want that cell to get user input, something like textfield, but other cells just static and not editable.
I know how to make custom cell and make it work, but before I dive into that option I would like to know is there a tweak that I could use.
I wonder it is possible without making all tableview in custom cell?
You can use UITableViewHeaderFooterView instead of last cell. I think it is better way to add some UI into TableView.
You just need to override a method which is here: https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITableViewDelegate_Protocol/index.html#//apple_ref/doc/uid/TP40006942-CH3-SW22
There is a simple example here:
http://www.ioscreator.com/tutorials/customizing-headers-footers-table-view-ios7
I hope that is helpful for you.
I can't find anything else on the internet about this specific topic. Everyone else wants to know how to do inline UIPickerView, but there is nothing on just having a UIPickerView appear over a table.
I have a TableView with a bunch of populated cells. I also have a defunct button in the top left of the screen. What I want is to be able to press the button, bring up a Picker and sort the TableView's cells based on what is selected.
I've been looking around and trying for ages and I just can't find anything detailing a solution to my problem.
I would try using ActionSheetPicker-3.0
It makes it easy to present a UIPickerView over your current view without having to use a delegate as it uses callback blocks.
im looking for a similar control to this Android Wheel, its very similar to UIPickerView, but i know that Apple use to reject APPs that modify UIPickerView appearance.
I need a control that let me put images on a infinite loop scroll and let the user drag to select one.
I've found some controls here, but most of them only support strings, some support images and are looped but dont let the user scroll.
My purpose is to make a button scroll loop where you can drag any button to the center of the wheel and see a text description on a uilabel, i dont need the buttons to be clickables.
I hope I explained well, and sorry for my bad english.
I would better suggest you to go with the iCarousel here. This enables you a different mode of scrolling & directions & effects which you can project on a Custom view similar (by Sliding-In & Sliding-Out from the bottom of screen) like a UIPickerView. This is not at all made using extending UIPickerView, but you can project it like that. Once you see a demo app of it, you can eventually change your mind to use this over custom UIPickerView.
Just implement the delegate method declared here to know which of the element was clicked. iCarousel comes with a image loading view also. You can look into that too.
But if you want to stick with UIPickerView customization, then please have a look at this stack Overflow post. This is certainly what you want, except that you need to add button instead of images.
I am very new to IOS development and Objective-C as i have just come from a mostly Java background. I have quite frankly searched everywhere on the web to find the answer to my question but nobody as it seems can give a clear concise answer on how to do this so anything would be VERY much appreciated!
So here is what i am trying to do. I have a UITableView and a UIToolBar below it with a UIBarButtonItem. What i want to do is be able to press the BarButtonItem and then have a new TableViewCell with a text field in it be created and placed at the top of the TableView that has a unique tag so that i can parse through the text fields later and retrieve the text to store into a mutable array.
Any help would be really awesome so thank you in advance, i would really like to get this working! If you have any questions on the code i have or more details on what i am asking please ask away!
Well there are plenty of resources on how to add TableViews, Toolbars, etc... Here's an overview of what you'll want to do.
In your ViewController's view, add a UITableView to it, but remember you want to leave space in your ViewController's view for the toolbar at the bottom of the screen. So set the tableView.frame accordingly.
Look up how to add a UIToolbar (http://stackoverflow.com/a/7712240/1457445 is a good start)
Then how to add a UIBarButtonItem (http://stackoverflow.com/questions/5383906/how-to-add-uibarbuttonitem-in-uitoolbar-in-code)
As for adding the textView in the UITableViewCell, you simply call [tableView.contentView addSubview:yourTextView];
Again, there is plenty of help out there for customizing UITableViewCells (http://stackoverflow.com/questions/4238760/how-to-make-a-uitableviewcell-with-a-uitextview-inside-that-dynamically-adjust)
And to top it off, you'll need to figure out how to add the textview cell to the table - another great SO post (http://stackoverflow.com/questions/5824998/uitableview-adding-cells-dynamically)
The simplest way is put your UITextField on UITableView header when UIToolbar button item touched. The simplest way is put your UITextField on UITableView header when UIToolbar button item touched. After user done on UITextField then update your NSMutableArray reload data of UITableView and remove header on UITableView.