My app tracks events. Users can create new events or join existing ones. Events have Title, Location, Start Date, optional End Date, etc.
I have a UITableViewController
to show the list of events, bog standard with one custom cell.
My data entry screen (see Image 2) to create an event is also a UITableViewController
, similar to the Apple iOS Calendar app's "New Event" screen (see Image 1). I created multiple Prototype Cells (one with a UITextField
, another with a UIDatePicker
, another with a UICollectionView
, etc.). The screen, as such, is working fine, but...
I'm trying to create an unwind segue like in this tutorial from Apple in the section "Create an Unwind Segue". Step 7 - no problem. Step 8 - eek!
In the tutorial, there are simple controls to collect the data, create a "Meal", add it to the array of meals and return to the list of Meals. But, I have a UITableViewController.
I have no idea how to collect the data in order to create my Event, add it to the array, etc.
Do I need to redesign my UI without using a UITableViewController
? It seems like the perfect UI for this scenario.
you can use Delegates to get the data from the Table xib to whichever controller you want,Hope this helps
1.Add this method on top of your xib's viewcontroller file
protocol ViewModelDelegate
{
func sendValue(from PassData: String?)
}
class XibViewController: UITableViewCell {
var controller:HomeViewController()
override func awakeFromNib() {
super.awakeFromNib()
controller.delegate = self
}
//call this method on any button action or save
controller.sendValue(from PassData:String?)
}
Create a function where you want to fetch all data into viewcontroller.
class:HomeViewController:UITableViewController { override func viewDidLoad() { super.viewDidLoad() } func sendValue(from PassData:String?) { //code to get the data from picker or textfield } }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.