Notification when table view row is deselected during multiselection IOS - ios

I have a table view with multiselection enabled. I want to call a webservice when the table row is selected and a different webservice when it is deselected. I have noticed that on table view selection the didSelectRowAtindexPath is called but its not called on deselection. Is there any way to trigger an event when a row in table view is deselected.

See the UITableViewDelegate methods tableView:didDeselectRowAtIndexPath: and tableView:willDeselectRowAtIndexPath:.

Related

UITableView reloadData does not make UITableView reload its data

I have methods implemented for datasources like heightForHeaderInSection or cellForRowAtIndexPath. I have a MasterView - DetailView class implementation which implemented on different class. When I open the MasterView which will then open a DetailView for an item I select on MasterView, the DetailView will call all the datasources (touch the breakpoints). But after I return to MasterView and select another item, it will open DetailView again but show the old data, and all the datasources breakpoints are not touched at all. I have called the [detailTableView reloadData] manually from MasterView after populating DetailView's properties with new data and before bring the DetailView to screen, but the table won't refresh. What went wrong?

how to expand and collapse multiple row and sub row in tableview

I have a table view. Now I want to collapse and expand rows by tapping on the section header. In other words, when I tap the header the rows display for that section and taping sub row its display other section How can I do this?
You can return your own header view by implementing tableView:viewForHeaderInSection: method (of table view data source). Here you can add tap gesture on header view. Hence when header view is tapped, you can maintain, which header view is tapped in some data structure and should it be expanded or not. Then you can call tableView reloadData method to reload the data and in tableView:numberOfRowsInSection:& tableView:cellForRowAtIndexPath: methods, you can check if this header view is to be expanded, you will prepare the cell for rows for this header view else you will not.

when cellforrow method of tableview will call

I have a tableView and it's already loaded.
When I am changing view I add that tableView in that view and make it hidden.
But I am not getting why cellForRowAt(:) call for that table?
When you are updating or scrolling your tableview cellForRow will get fired. There is no chance for scrolling here because you already hide the tableview.

iOS- Table row/cell behaviour when it has a details disclosure button?

In my tableview I have a set number of rows and all have a detail disclosure button, clicking on detail disclosure button takes the user to a new view displaying info in a text view. I am not able to conclude on how the row should behave when user taps it because the Apple guidelines for table view and for detail disclosure button is confusing.
Please can anyone explain the below 2 scenarios for me. Thanks in advance.
Is it correct that the new view slides in only when the user taps the detail disclosure button and nothing happens when user taps elsewhere in the row.
What should be the behaviour if the user taps on the detail disclosure button with regard to highlighting?
What should be the behaviour of the table row if user taps elsewhere in the row ?
Apple guidelines says "When a detail disclosure button appears in a table row, tapping elsewhere in the row does not activate the detail disclosure button; instead, it selects the row item or results in app-defined behavior."
and Apple table view guidelines says "A table row highlights briefly when the user taps a selectable item. If a row selection results in navigation to a new screen, the selected row highlights briefly as the new screen slides into place. When the user navigates back to the previous screen, the originally selected row again highlights briefly to remind the user of their earlier selection (it does not remain highlighted)."
When you tap on the row this delegate method is invoked:
– tableView:didSelectRowAtIndexPath:
When you tap on detail disclosure button the following delegate method is invoked:
– tableView:accessoryButtonTappedForRowWithIndexPath:
tableView:accessoryButtonTappedForRowWithIndexPath:
Tells the delegate that the user tapped the accessory (disclosure)
view associated with a given row.
- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
Parameters
tableView
The table-view object informing the delegate of this event. indexPath
An index path locating the row in tableView.
Discussion
The delegate usually responds to the tap on the disclosure button (the
accessory view) by displaying a new view related to the selected row.
This method is not called when an accessory view is set for the row at
indexPath. Availability
Available in iOS 2.0 and later.
Declared In UITableView.h
tableView:didSelectRowAtIndexPath:
Tells the delegate that the specified row is now selected.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath Parameters
tableView
A table-view object informing the delegate about the new row selection. indexPath
An index path locating the new selected row in tableView.
Discussion
The delegate handles selections in this method. One of the things it
can do is exclusively assign the check-mark image
(UITableViewCellAccessoryCheckmark) to one row in a section
(radio-list style). This method isn’t called when the editing property
of the table is set to YES (that is, the table view is in editing
mode). See "“Managing Selections”" in Table View Programming Guide
for iOS for further information (and code examples) related to this
method. Availability
Available in iOS 2.0 and later.
See Also
– tableView:willSelectRowAtIndexPath:
– tableView:didDeselectRowAtIndexPath:
Declared In UITableView.h
Reference : UITableViewDelegate
You can do whatever you want with this discloure button. 1)New views can slide event if will tap on row. 2) nothing 3) you can dot whatever you want: show new UIViewController, UIAlertView etc. It depends on your imagination. There are no restrictions for this.

Actionsheet instead of segue when clicking on uitableviewcell

Here's my ultimate goal in all of this. I have a viewcontroller with a table added to the view. I've set the cells to static, and I'm going to place the selected options in the cell. I want an actionsheet with a picker view on it. I have several arrays on the view which contain the various options. When someone clicks the cell I want it to call a method which checks which cell was click, passes the picker view the correct array of options to display and shows the action sheet.
I've manually added a table to the view using the storyboard, but when I ctrl drag from a cell it only gives me the option to add a segue. How do I set it so the cell click just goes to a method I create?
See UITableViewDelegate
(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- tableView:willSelectRowAtIndexPath and - tableView:didSelectRowAtIndexPath: should work. Did you try them? Your viewController needs to adopt UITableViewDelegate.

Resources