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

Error when trying to load next View from nib

This is what I'm trying to do in TalbeViewController.m: - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [tableView deselectRowAtIndexPath:indexPath animated:TRUE]; if(indexPath.row==0) { …
ingenspor
  • 924
  • 2
  • 15
  • 37
0
votes
2 answers

Table View cell image dissappear and reappear on selection

I have a custom UITableViewCell class. I am toggling between accessoryTypes of UITableViewCellAccessoryCheckmark and UITableViewCellAccessoryNone when didSelectRowAtIndexPath is called. Here's an example of what the cells look like before and…
kturner
  • 1,091
  • 2
  • 10
  • 15
0
votes
1 answer

Modify tableview (lied on another view controller ) based on table row selected

How to change the Images in table view which is lied in the new view controller based on row selected . e.g. Say I hv category table in my Category view controller.Now when user taps on Camera,a new view controller should load containing all the…
iCoder
  • 1,298
  • 1
  • 9
  • 25
0
votes
1 answer

UITAbleView cell selection affect another UITableView cell in same UITableView

I am developing an iPhone application with UITableView. I have implemented a check mark on each cell with didSelectRowAtIndexPath delegate. Now I want to select a cell that disable all other cells (remove the check marks) and vice versa (eg: to…
John
  • 734
  • 3
  • 14
  • 30
0
votes
1 answer

segue didSelectRowAtIndexPath can't pass string

I am trying to pass a string between two view controllers in a storyboard, core data program. The way I have it set up I want the next view to be pushed only for one section only. Hence the use of "didSelectRowAtIndexPath" rather than…
0
votes
1 answer

Checking/Unchecking a tableviewcell with sections

Previously, I had a large-ish dataset (~530 records) being displayed in a tableview. The data was held in an array of dictionaries with two keys, ID and name. Previously, I tapped a cell, it added a check mark, and it sent the cell row number to a…
Alex
  • 3,031
  • 6
  • 34
  • 56
0
votes
2 answers

didSelectRowAtIndexPath when select can't turn to other pages

if(!_personViewController) { _personViewController=[[PersonViewController alloc]initWithNibName:@"PersonViewController" bundle:nil]; } _personViewController.user=_user; [self.navigationController…
kabi
  • 131
  • 1
  • 1
  • 5
0
votes
1 answer

Change link in UITableview didSelectRowAtIndexPath

I have a feed that lists news items, click on one and you get taken through to the detail view. I do this through the didSelectRowAtIndexPath method where I declare the detail view controller etc. Is it possible to have a mixed feed whereby some of…
Full Time Skeleton
  • 1,680
  • 1
  • 22
  • 39
0
votes
2 answers

iPhone - UITableView not calling didSelectRowAtIndexPath method in 3.0 SDK

I have an iPhone app that works fine in 2.x version of the SDK. When I upgraded to 3.0, the didSelectRowAtIndexPath method is no longer called, so the action when a user highlights a row doesn't happen. This is a custom UITableViewCell that is in…
Tai Squared
  • 12,273
  • 24
  • 72
  • 82
0
votes
1 answer

didSelectRowAtIndexPath won't fire when moved offscreen

I have a UITableView that is initially offscreen and when a button is pressed, I shift the center point of the view to the right, moving the tableview back on the screen. Similar to the menu in Facebook. //Slide in Side Menu [UIView…
DavidB
  • 191
  • 1
  • 4
  • 14
0
votes
3 answers

Make a Call from UITableViewCell

I stuck with a problem. In my tableView I got a cell with a phone number. I would like to click on the phone number and make a call. I implemented the following in didSelectRowAtIndexPath: NSString *cifra=@"tel://123456789"; [[UIApplication…
0
votes
2 answers

iPhone : How can we load a custom check mark image for row in tableview?

I want to show a custom checkmark and uncheckmark image for tableview cell when user select any row and when a new row is inserted cell is loaded with uncheckmark image. Once I check the row then even after reloading table with new data I want to…
RayofHope
  • 1,187
  • 2
  • 14
  • 30
0
votes
1 answer

iOS: Horizontal UITableView inside another UITableView issues

I want to create a table with horizontal scrolled rows. I have followed Felipe Laso's tutorial in Raywenderlich's blog, here. It works perfectly except for 2 issues. First, the inner horizontal table should have a dynamic number of cells based on an…
0
votes
1 answer

make "Next" Button disabled if no cell is checked

THX FOR THE HELP! I changed the Viewdidload like that and it is working fine for me now! Iam Fetching the location and took a predicate to synchronize the checks and the state of the button - (void)viewDidLoad { [super viewDidLoad]; app…
Bashud
  • 266
  • 2
  • 8
  • 20
-1
votes
1 answer

Why the property does not pass to another view Controller?

extension ReservationViewController: UITableViewDelegate { func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { if let vc = storyboard?.instantiateViewController(withIdentifier: "restaurantDetail") as?…