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

Selected cell Image will display in UITableView

I have a UIImageView added as subView in the default UITabelViewCell. When I click on the cell, the UIImageView should display image the in selected cell. How to do that? - (UITableViewCell *)tableView:(UITableView *)tableView…
user2841148
  • 711
  • 1
  • 8
  • 11
0
votes
1 answer

didSelectRowAtIndexPath is not working in ios6 with side menu

I am working in application witch contain side menu . when i select option in side menu its display UItableview, this Table is inside FirstViewController, when i select particular row in firstViewController its not navigate to SecondView…
0
votes
1 answer

Can't do a tableView Cell Action

I have a UITableView and I want there to link to the Apple website when the user taps the first cell or row in the UITableView. This is my code: - (void)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { if…
MicahKE
  • 125
  • 1
  • 1
  • 7
0
votes
4 answers

What is the best way to check if my UIView has already been shown?

what is the best way to check if my UIView has already been shown on the screen. I have UISplitViewController in which I tried to display details in custom UIView after tap on tableViewCell. All I wanna do is to avoid duplication of the view that…
sonoDamiano
  • 185
  • 1
  • 12
0
votes
1 answer

NSArray objectAtIndex index 1 bounds beyond [0,0]?

My problem is that the first cell in each section works but if I have another cell in that section (index 1) it just crashes with that error. I realize this question has been asked many times, but I have referenced the other questions and not have…
0
votes
1 answer

using didSelectRowAtIndexPath to push saved data viewcontroller

I have a tableview that show saved data, but when I try to go from selected cell, it doesn't show the data that's been saved. It try this I used NSUserDefaults to save data in other view (another .m file) -…
0
votes
1 answer

How to set an image in table cell permanently after reload?

I have a test for whether a cell was clicked by the user. If it was clicked, the image changes. I want that image to remain checked, even if the user clicks it again or the app reloads. It's really close to working. Right now, the image changes…
CharleyB
  • 41
  • 1
  • 6
0
votes
1 answer

Xcode wrong object passed to UIViewController

I have an iPhone application that reads the details of local businesses from a .csv file. There are 3 main section: Where to Sleep Where to Eat What to Do Depending on which one is clicked (e.g. Where to Sleep), you get a sub section of options…
heyred
  • 2,031
  • 8
  • 44
  • 89
0
votes
1 answer

NSIndexPath not working on DidSelectedRow with AlertView Function

in tableView didSelectRowAtIndexPath: (NSIndexPath *) indexPath I inserted a alertView which contains a text that changes depending on the cell clicked .. The action of the button "SEND" nell'alertView must save the contents of the label present in…
kAiN
  • 2,559
  • 1
  • 26
  • 54
0
votes
2 answers

how to pass data to subview controller in ios app from the calling method didSelectRowAtIndexPath

Could somebody explain me what i'm doing wrong in the code below? I try to pass data from the didSelectRowAtIndexPath method but in the SizeViewController productKey has still value of null -(void)tableView:(UITableView *)tableView…
sonoDamiano
  • 185
  • 1
  • 12
0
votes
1 answer

Text Animation within didSelectRowAtIndexPath:?

I'm using an MCSwipeTableViewCell so the idea is that the user swipes it left or right to complete actions. However the user may not always be familiar with this action so when they tap the cell (expecting to select it) I want the text to briefly…
0
votes
1 answer

Share didSelectRowAtIndexPath selection in an array, between 2 controllers

On my never ending quest to share a table row selection to multiple views loaded in a modal view, I have got it down to one issue. I am using Apples DrillDownSave sample code as a model to recreate this magic. And think I have it all set up exactly…
0
votes
2 answers

call multiple view controller in didSelectrow uitableview

i am using two protocol something like this: @protocol ModalClosedProtocol -(void) modalClosedGlobalProtocolMethod; @end and syncmlClient Protocol. There are three classes ContactsViewController, EventViewController,…
maddy
  • 4,001
  • 8
  • 42
  • 65
0
votes
1 answer

How to select UITableViewController row from ANOTHER ViewController?

I'm using JASidePanels for my App (Facebook menu style). The LeftPanel is my menu (tableView) and the CenterPanel where I display my contents has a collectionView. When I tapped an item in the center collectionView, I would also like to selected the…
user2570984
0
votes
1 answer

Slow Network - DidSelectRowAtIndexPath delayed

I have a table that is refreshing itself every two seconds. It works great on the simulator and on my wifi. But once I switch to the cellular network (or any slow network), I cannot select the rows reliably. Sometimes when I click a row it will…
AllieCat
  • 3,890
  • 10
  • 31
  • 45