Questions tagged [didselectrowatindexpath]

iOS - didSelectRowAtIndexPath: is a UITableView delegate method which is called when the user selects a row on a table view. Navigation logic goes here.

– tableView:didDeselectRowAtIndexPath:

iOS Method within UITableView (Apple Docs)

Full method decleration:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;

Overview

didSelectRowAtIIndexPath: is a method part of the delegate. The UITableView delegate handle setup and events for a UITableView.

This method is called when a user selects a row in the table view, and takes an argument of NSIndexPath. The NSIndexPath contains the row, and section of the cell which was selected. Within this method, actions are performed to react to a user's selection.

Unlike this method, willSelectRowAtIndexPath: is used to allow or disallow a selection based on the index path.

Similar methods include:

– tableView:willSelectRowAtIndexPath:
– tableView:willDeselectRowAtIndexPath:
- tableView:didDeselectRowAtIndexPath:

Sample Code

An implementation of this method designed to handle navigation logic might look like this:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *) {
    NSUInteger row = [indexPath row]; // Easier to cache row, esp. in long methods

    // In viewDidLoad you would have set up an array of controllers, then:
    UIViewController *childController = [controllerArray objectAtIndex:row];
    [self.navigationController pushViewController:childController];
}
629 questions
0
votes
2 answers

didSelectRowAtIndexPath get called just once

i have two view controllers, FirstViewController and DetailViewController, switch back and forth. in didSelectRowAtIndexPath method ---> updateRowNumber:indexPath.row, i pass the selected row number to DetailViewController. the first time, it…
max
  • 645
  • 3
  • 11
  • 22
0
votes
2 answers

TableView won't allow me to press up and transfer view. Obj-C, Cocoa Touch

So I have an app that contains a tableView. When you press on a row, it should go to a new view controller and transfer the results. But it only sort-of works. If you press on a row, it will stay selected (Highlighted blue), but then if you select a…
Josiah
  • 4,663
  • 2
  • 31
  • 49
0
votes
1 answer

How to get selected row from UITableView with Search Display Controller

I have my search display view controller based off TableSearch. Normally, following expression gives selected index row: self.tableView.indexPathForSelectedRow.row However while in search mode, selected row can be obtained…
0
votes
1 answer

U_ILLEGAL_ARGUMENT_ERROR crashing my application

This is the error I am reciving when I select a value from my UITableView *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Can't do regex matching, reason: Can't open pattern U_ILLEGAL_ARGUMENT_ERROR (string…
HurkNburkS
  • 5,492
  • 19
  • 100
  • 183
0
votes
2 answers

Pushview on didselectrowatindexpath in storyboard

I have a tableview added as a subview in one of the viewcontrollers in storyboard. It has 6 sections each having one row. On selecting each row a new viewcontroller should open. There are 6 such different viewcontrollers for that. I dont know how to…
0
votes
2 answers

Xcode didSelectRowAtIndexPath on tableview not called

I have been looking until 6 o'clock this morning, but I can't figure out why the didSelectRowAtIndexPath method is not being called. I am getting quite desparate on this one. The tableview is shown properly, but I cannot succeed to enable the…
html_programmer
  • 18,126
  • 18
  • 85
  • 158
0
votes
1 answer

tableView.setScrollEnabled is No, DidSelectRowAtIndex not responding

If tableView.scrollEnabled = NO, then didSelectRowAtIndexPath is not responding to first touch, but only to the second select row. Do you have any idea why?? Please help.
0
votes
1 answer

UITableView reusable cell or not

I'm developing an app that represents a huge amount of data using UITableView with a custom UITableViewCell. When the tableView is set to editing mode, it supports multiple selection for further usage of the selected set of data. Using…
Julian F. Weinert
  • 7,474
  • 7
  • 59
  • 107
0
votes
1 answer

UITableView cellForRowAtIndexPath checkmark accessory setting acting weird

Setup: I have a property called "_itemListArray(ivar)", that is set to a list of "Item(NSString itemName, NSString itemPrice)". I populate a UITableView with these items and the user can select multiple rows, displaying a checkmark on that row. The…
0
votes
1 answer

UiTableview Sequeing with didselectrowAtindex returns previous selection?

i hope someone can please help me with this. Im doing something really wrong here. Im trying to seque to a detailview. The problem is that the first time i select it, it returns a nil value, the second, third, etc time it returns the value i…
JsChoice
  • 109
  • 8
0
votes
2 answers

didSelectRowAtIndexPath really doesn't work

The didSelectRowAtIndexPath not working. Have I configured the 2 delegates. Everything is linked (tableview, tableviewcell). Already deleted and did it again. I searched for everything here and nothing worked. I think this was one of the best link,…
0
votes
1 answer

Xcode alert button

I have this code which will send me to another page but this only happens upon selecting a row in the picker. - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{ NSString *urlString; if…
0
votes
1 answer

Xcode reuse detail view for multiple table views

I have multiple table views that display different items. The detail view for each cell though should have the same layout. I want to use the same detail view for all the cells of each table without having to implement a different detail view class…
apples
  • 13
  • 1
  • 6
0
votes
1 answer

iOS Dynamic Button tagging in UITableViewCell does not detect correct row in table

I'm experiencing a major problem now as my renewal button does not detect the row that is being selected at all because of the recycling! Tried tagging the button but it doesn't detect the correct button either. Please help! I've been stuck on this…
user1418174
0
votes
1 answer

indexPath.row Returns Random Cell TextLabel in didSelectRowAtIndexPath

I have a UITableView populated by a SQLite database. I added Section-based Grouping using the sectionIndexTitlesForTableView delegate method today and now when a Cell is selected, the String for indexPath.row is not the same as the text in the…
Giz
  • 199
  • 1
  • 15