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
10
votes
2 answers

Properly setting up willSelectRowAtIndexPath and didSelectRowAtIndexPath to send cell selections

Feel like I'm going a bit nutty here. I have a detail view with a few stand-alone UITextFields, a few UITextFields in UITAbleViewCells, and one single UITableViewCell that will be used to hold notes, if there are any. I only want this cell…
Gordon Fontenot
  • 1,370
  • 3
  • 17
  • 38
9
votes
1 answer

autocorrect in UISearchBar interferes when I hit didSelectRowAtIndexPath

I have a Searchbar that generally works. The problem comes when I test on the iPhone, the autocorrect kicks in. I have the search bar set that if there is text in the query bar > 4 in length,then it starts putting things into the searchResults…
9
votes
3 answers

UICollectionView inside UIView container: didSelectRowAtIndexPath doesn't get called after scroll

I have 3 UIViews Header / Tabar / Container embedded un a ScrollView in a ViewController. So this is my structure : In the ContainerView I load a UICollectionView (like this) : let controller =…
9
votes
2 answers

App crashes on call to 'tableView endUpdates'

I'm currently working on an implementation of an inline UIDate picker inside of a UITableViewCell. I'm able to show and hide this picker cell when I select the cell directly above where that cell should be inserted, which is the behavior that I…
narner
  • 2,908
  • 3
  • 26
  • 63
8
votes
6 answers

How do you change the textLabel when UITableViewCell is selected?

I want to change the textLabel and detailTextLabel of a cell when it has been selected. I've tried the following, but no change occurs: - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { MyAppDelegate…
Ike
  • 81
  • 1
  • 1
  • 2
7
votes
3 answers

How to detect that UITableView is in editing mode?

I have a situation in which I am putting the UITableView in editing mode, and when it is not in editing mode, it has to perform tableview: didSelectRowAtIndexPath: and has to be pushed on a UINAvigationController. Now the problem is that how can I…
7
votes
2 answers

TableViewController Detect Row Tap with Static Cells

I'm using a TableViewController that has a table with 2 sections of static cells. This is embedded in a view controller. I cannot get didSelectRowAtIndexPath to run when I tap the cells. I've already check all of the usual suspects from this…
user1715916
  • 333
  • 5
  • 13
5
votes
3 answers

UITableView didSelectRowAtIndexPath add additional checkmark at tap

When i select a player in 'didSelectRowAtIndexPath' and add a checkmark on the selected row it adds an additional checkmark. If i tap row = 0 it adds a checkmark to row = 0 and row = 11. This means that two row's are marked by one tap. If i tap row…
PeterK
  • 4,243
  • 4
  • 44
  • 74
5
votes
6 answers

iOS: clicking on a view inside a TableCellView

I placed a small UIView inside a UITableViewCell. In case of a tapping on such UIView, I would like to open a popup. In case of a tapping outside such UIView, I would like to perform what it's defined in the UITableView "didSelectRowAtIndexPath"…
Daniele B
  • 19,801
  • 29
  • 115
  • 173
5
votes
2 answers

UITableViewCell tap on subview without cell selection

I have a custom tableviewCell with an UIImageView imgView inside. I added UITapGestureRecognizer to imgView, so that I can change image of imgView whenever I tap to it. However, when I tap to imgView, didSelectRowAtIndexPath is also triggered. What…
5
votes
0 answers

Selenium - Return Xpath of clicked element

I'm developing Selenium tests in java, and i'm looking for a solution for my problem. I want to click on a zone ( coordinates ) of an element during the test. This click implicitly returns me the Xpath of the clicked element present in this zone, in…
MxfrdA
  • 171
  • 3
  • 14
5
votes
1 answer

Tree TableView with multiple NSMutablearray

I am try to make tree table like shopping app(main name,category name and sub category name) but not getting proper.i am using NSMutableArray please help me. example Like ::: Laptop (main name) ,Company (Category Name),Model (Sub Category Name) My…
5
votes
3 answers

Selecting and Deselecting UITableViewCells - Swift

Currently I am able to tap a cell and select it using didSelectRowAtIndexPath. However, I am unable to deselect it when tapped. I wish to toggle these two features. func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath:…
JohnJLilley
  • 173
  • 1
  • 2
  • 10
5
votes
2 answers

swift, convert NSIndexpath to Int

I have a tableview with a button in each cell. When that is tapped I have a didselectrow function. I want to use my indexpath to get a value from an array that gives the cells contents. How can I convert this NSIndexpath to an int to use in the…
Vincent
  • 51
  • 1
  • 2
5
votes
4 answers

UITableViewController changing one reusable cell affects other cells

I have a very simple UITableViewController subclass designed to show users the characters in the alphabet in cells. When the user presses on a cell, it is to set its accessory type to a checkmark. #import "MTGTableViewController.h" @interface…
michaelsnowden
  • 6,031
  • 2
  • 38
  • 83
1
2
3
41 42