I have a table that the user is viewing. When the user shakes his device, I want a random row to be selected. How to do it?
I have a sign of shaking, I can create a random integer that does not exceed the number of lists, but I can not find the correct code so that this line is highlighted in the table.
In the Apple documentation, I found:
NSIndexPath *rowToSelect; // assume this exists and is set properly UITableView *myTableView; // assume this exists [myTableView selectRowAtIndexPath:rowToSelect animated:YES scrollPosition:UITableViewScrollPositionNone; [myTableView scrollToRowAtIndexPath:rowToSelect atScrollPosition:UITableViewScrollPositionNon animate:YES];
but I can't get it to work. I have a UITableView *myTableView . I used a randomized integer like rowToSelect.
source share