In WWDC 2013 video, Apple suggests displaying picker in place in a table view in iOS 7. How to insert and animate a view between table view cells?
Like this, from the Apple calendar app:
In WWDC 2013 video, Apple suggests displaying picker in place in a table view in iOS 7. How to insert and animate a view between table view cells?
Like this, from the Apple calendar app:
Here is another way to solve the problem without static constant numbers. All the cells can be used in static and dynamic table views. This method uses single cell for both title and date picker!
Btw you can have as many date pickers in your table as you wish!
Create a UITableViewCell subclass:
Create a CPDatePickerTableViewCell class from our CPTableViewCell
In your view controller implement these two delegate methods
Example how to set up constraints in Interface builder
Additionally I have written custom cell classes for UITextField and UITextView where tableView:didSelectRowAtIndexPath: is called when cell is selected!
CPTextFieldTableViewCell
CBTextViewTableViewCell
Cell height is dynamic and row will grow when text is wrapped to new line!
I have made my own custom view controller to simplify the process of adding an inline picker inline in a tableview. You just subclass it and follow some simple rules and it handles the date picker presentation.
You can find it here along with an example project that demonstrates how to use it: https://github.com/ale84/ALEInlineDatePickerViewController
The easiest way to use DateCell in Swift version: Use this example.
Drag "DateCellTableViewController.swift" class to your project.
Open "Main.storyboard" and Copy "DateCell" ViewController Object and past it in your storyboard.
One of the best tutorials about this is iOS 7 in-line UIDatePicker – Part 2. Basically here I use static table view cells and implement some additional methods. I used Xamarin and C# for this:
You have to active
Clip Subviews
.Setting the height:
Than a class variable:
private bool datePickerIsShowing = false;
Show date picker:
Hide date picker:
And calling this functions:
Using the storyboard and a static table I was able to achieve the same result using the following code. This is a great solution because if you have many oddly shaped cells or want to have multiple cells that are dynamically shown/hidden this code will still work.
With iOS7, Apple released the sample code
DateCell
.You can download the sample code here: DateCell.