Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Manually trigger cell select TableView

I need to manually programmatically trigger a cell select on my tableView. Essentially running the pre-made function

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

I'm doing this in order to when an item is deleted from the tableView it will automatically load the next item. However when I try to manually call this function it can't seem to be found. I've tried

self.tableView: didSelectRowAtIndexPath

and

[tableView didSelectRowAtIndexPath]

but neither is recognised.

like image 391
Flatlyn Avatar asked Jul 27 '12 13:07

Flatlyn


People also ask

How do you make a tableView Unselectable?

To actually prevent selection you need to implement tableView:willSelectRowAtIndexPath: on your UITableViewDelegate and return nil for non-selectable rows.

What is tableView?

A table view displays a single column of vertically scrolling content, divided into rows and sections. Each row of a table displays a single piece of information related to your app. Sections let you group related rows together. For example, the Contacts app uses a table to display the names of the user's contacts.

What is didSelectRowAt in Swift?

tableView(_:didSelectRowAt:)Tells the delegate a row is selected.


2 Answers

[self tableView:self.tableView didSelectRowAtIndexPath:selectedIndexPath];

replace selectedIndexPath with whatever the next row is

make sure self is your table view delegate

edit: I know this is an old question but really this should be done with [tableView selectRowAtIndexPath:path animated:YES scrollPosition:UITableViewScrollPositionMiddle];

like image 176
wattson12 Avatar answered Sep 28 '22 09:09

wattson12


You should try:

[self tableView:self.tableView didSelectRowAtIndexPath:YourIndexPath]
like image 30
The dude Avatar answered Sep 28 '22 09:09

The dude