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
-1
votes
1 answer

Cannot assign to property: '$0' is immutable

I have my default selected cell in my table view. I want to change this selected language when tapped but could not able to do so. I am getting an error at '$0' line: var languageViewModel = LanguageViewModel() var languageTitles: [LanguageModel] =…
Mert Köksal
  • 817
  • 1
  • 7
  • 26
-1
votes
1 answer

How to make 2ndVC tableview didSelectRowAt working only if i come from 1stVC btn tap in swift

I have two Viewcontrollers.. in 2ndVC i have tableview.. here i dont want didSelectRowAt method to work.. i need only this method to work when it navigates from 1stVC btnAction in 1stVC textfield i need to fill with 2ndVC tableview's selected row…
-1
votes
1 answer

TableView didSelectRow could not perform as expected result

As per the video shown, I want the TransactionListViewController to show the cell selected from AccountViewController as selected. However, TransactionViewController shows only Section 0 Row 0 & Section 0 Row 1, while others section & row keep…
-1
votes
1 answer

UITableViewDelegate didSelectRowAt Conditionally Execute based on Row

I am interested in being able to conditionally execute code based on what row a user selects. Is there a way to associate an identifier with each row (cell) in cellForRowAt to help distinguish which row is selected to be used in DidSelectRowAt…
Kevin
  • 1,189
  • 2
  • 17
  • 44
-1
votes
2 answers

Binary operator

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { let firstPart = URL(string: "https://www.kiva.org/lend/") let secondPart = loans[indexPath.row].id let result = firstPart + secondPart …
-1
votes
2 answers

Open TableView To Last Clicked Cell

I have a tableview list with clickable cells, when one is clicked a new viewcontroller opens up. When a back button is clicked and the first VC is called, the tableview resets to the top of the list. How can I change this so when the back button is…
AceVentura
  • 13
  • 4
-1
votes
1 answer

Convert Multiple Selection DidSelectRowAtIndexPath from Objective C to Swift 3

I am in the process of converting my app from Objective C to Swift. I doing well in all areas with this exception. In my objective c file I have a UITableView that allows multiple selections. When the user selects a cell, information from that…
-1
votes
2 answers

how to assign an array element in a indexPath from selected cells

I have an array with sound list NSArray *nameSound = @[@"alarm-1.wav",@"alarm-2.mp3",@"alarm-3.mp3",@"alarm-4.mp3",@"alarm-5.mp3"]; And I have TableView with 5 cells, How award for indexPath from TableView to element from nameSound P.S. Sorry for…
-1
votes
1 answer

Get IndexPath of UITableView to change the color of a UIView

I added a badge to the left of my tableViewCell as it is shown in this example. Then after getting that successfully done I moved to the next thing which is to add a swipe left/right on cell and show some options. I've successfully configured it by…
Chaudhry Talha
  • 7,231
  • 11
  • 67
  • 116
-1
votes
2 answers

didSelectRowAtIndexPath is not work

the cell is very simple, just a textLabel. i want to tap the cell and then print some words. this is a test . but the didSelectRowAtIndexPath is not work. Please tell me why, thank you ! import UIKit import SnapKit class ListTableViewController :…
carly
  • 11
  • 3
-1
votes
1 answer

didSelectRowAtIndexPath is not changing the property I am passing to a previous View

I am trying to pass data from a tableview to a previous screen, which is my Sign Up screen. Specifically what I am sending is the name of a school. What is happening is that when I return to the previous screen through the segue, the label I am…
Anthony Saltarelli
  • 345
  • 1
  • 4
  • 15
-1
votes
2 answers

Buttons in UITableViewCell

I have a UITableViewCell with a button inside it, when I press the button, it moves onto the next view, but I need to pass the index of the TableViewCell, but I cannot find this because it is NOT in DidSelectCellAtIndexPath, it is only the button…
-1
votes
2 answers

My UITableView cell is not giving me the right information

I have close to 30 cells being occupied in my UITableView. I used storyboard mode to create the table. When I'm trying to call the cell that I selected its registering as 0 no matter what cell I've chosen. How do I get my cell to register the exact…
Thomas Martinez
  • 1,631
  • 3
  • 16
  • 21
-1
votes
5 answers

'didSelectRowAtIndexPath' detecting too many rows

I'm working on implementing an inline date picker in a table view. However, I'm struggling on a problem with 'didSelectRowAtIndexPath'. The sections and rows of the tableView are defined using NS_ENUM, as shown below: typedef NS_ENUM(NSInteger,…
narner
  • 2,908
  • 3
  • 26
  • 63
-1
votes
1 answer

How to select single row in every section?

I'm building an iOS app using storyboards. I have implemented UITableView with two sections like Alpha a b > Numb 1 > 2 3 I want to select single row in every section and get the value of selected row. I'm unable to do this, can somebody…
Hitesh
  • 41
  • 1
  • 2
  • 10
1 2 3
41
42