I show EKCalendarChooser in popover. When user selects a calendar in the chooser I get its calendarIdentifier. Everything goes smooth till this point but When you reopen the popover the selection in the chooser disappears. How to maintain the selection or how to reselect the calendar again when user open the chooser popover again.
If EKCalendarChooser is normal UITableView I can easily match my db value with that of the displayed cell and make it selected. But here how do I set EKCalendarChooser tablecell selected? I do have the calendarIdentifier...any Ideas?
plz help me out.
Thanks in advance.
As the user works with the EKCalendarChooser, use the calendarChooserSelectionDidChange: delegate method to keep track as the user changes the selection. You can store the selectedCalendars property value each time this method is called.
Then, the next time the EKCalendarChooser appears, set its selectedCalendars property to the selection you previously saved.
Try to build a data layer to your application with reference to MVC design pattern see here.
Save the popover selection state (and the other data) at the data layer (model).
After that, access this data layer (model) each time u open the popover and configure the popover according the data.
Anyway, to to make cells selected or deselected in UITableViewDelegate methods:
tableView:didSelectRowAtIndexPath:
tableView:didDeselectRowAtIndexPath:
Related
I have a UITableViewController that comes on to the screen in a popup. Basically it slides in from the left and shows the hierarchy available.
When it comes on screen, I select an item within it to represent the current location. Before today, this all worked.
Today I added a UITextView as a header to the table. Since then, my selection is acting strangely. When the UITableViewController appears, I can see my selected row get selected briefly, but it immediately becomes unselected. Calls to indexPathForSelectedRow return nil.
Is there a way to be alerted whenever the selection changes in UITableView? I know to use tableView:didSelectRowAtIndexPath: to keep track of when the user selects an item, but this problem is happening without user input. I'm assuming I've done something incorrect within the code, but I'm trying to track it down without posting all my code here.
Edit
Apropos of nothing, I did find that the problem goes away if I remove the Navigation Controller that I had added to the UITableViewController. This was because I had not set the property clearsSelectionOnViewWillAppear to NO. By adding the Navigation Controller, the UITableViewController was getting loaded differently, causing the property to actually be used.
However, I still would like to know how to be alerted to table view selection changes.
I'm going to make this VERY simple because for the past week people are getting confused with this same exact question. I have on TableViewController. When a user taps on a cell on my TableViewController it goes to a DetailViewController which has a button called PAID. When the user taps on the PAID button in the DETAILVIEWCONTROLLER I want that specific cell that I tapped in the HISTORYTABLEVIEWCONTROLLER to be marked PAID. I don't care how it gets marked I just want it done. Im using core data and I've already created a "paid" attribute. So I would also like the cell to be SAVED as PAID.
All help is appreciated, thanks in advance.
Sincerely, About to throw my iMac out the window
There a multiple ways you could accomplish this. One way is to pass both the managedObjectContext, and the selected managedObject to the detail controller. In the "Paid" button's action method, set the value of the "paid" attribute for that passed in object, and call save: on the managedObjectContext. As far as marking the cell, you should have that (a string "Paid" or whatever other kind of mark you want) tied to the value of the "paid" attribute, so once your database is updated, that should be reflected in the table view.
If you use core data, It will be quite simple to achieve this.
In your detail view, modify paid attribute in core data, and save.
In table view controller, observe NSManagedObjectContextObjectsDidChangeNotification notification. If core data changed, notification callback will get called. Then change the tableview's datasource and update table cell.
I have a hierarchy of table views similar to iPhone Settings app. I'd want to do something similar to the done in General > International > Region Format: I navigate to a view with a table showing a list of selectable cells, and I want to be able to show the selected entry as a subtitle in blue when navigating back (as the "Region Format" cell does, showing the current selected region).
How should be the best way of getting this selection once navigated back to the parent view?
Thanks
You need to handle tableView:didSelectRowAtIndexPath: in your second view's delegate and save your information there. Then in viewWillAppear on your first view controller just pull in that value.
If you are using this for a preference in your app then NSUserDefaults would probably be a good place to store it.
I have a UIDatePicker in a view whose controller is in a UINavigationController. I'm registering changes in the selected date like this:
[self.datePicker addTarget:self.alarm action:#selector(timeChanged:) forControlEvents:UIControlEventValueChanged];
It works well, except if the user presses the back button in the UINavigationController before the date picker has completely settled. In that case, the timeChanged: method isn't being called, and so I'm not getting the new date.
Nothing is being released when I press the back button, it's just that the view controller is being popped off. (A reference to it is maintained).
I've found solutions to this problem with UIPickerView that involve implementing delegate methods for the picker view (eg: UIPickerView: Get row value while spinning?). But unless I'm very mistaken, that's not an option with a UIDatePicker. If possible, I'd like to stick with the UIDatePicker rather than a custom UIPickerView. Is there a way to do this? It doesn't have to get the selected row perfectly (within a row or two is fine), but the closer the better.
EDIT: This is for a jailbreak app, so private APIs are fine, if I can figure out what they are.
As for the current APIs, there's no way of detecting whether a UIDatePicker is spinning.
This is because UIDatePicker is not a subclass of UIPickerView and it manages a UIPickerView internally.
I'm afraid the best solution here is to use a custom UIPickerView.
I have a UI table view loading data from network. If the user move the finger on one cell, one button will be displayed, just like iPhone style delete button. If the user click this button, the value of one label in the cell will be changed accordingly. However, I didn't find any way to make table view to re-draw this cell, except for reload the whole table. I don't want to use reload data method, because I just need change the value in one cell instead of the whole table. Any suggestion on this?
Take a look at the method
- (void)reloadRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation
Calling this method will result in your table view's data source asking its delegate for information about that cell.
For future reference, I found this very easily by checking the documentation on UITableView. I suggest you do that in the future before posting here.