I have a UITableViewController and want to move down a cell in my table every time the accelerometer’s X axis is greater then 0.5 (when this event occurs i increment a value named “TEST” ). How can i change the background of a cell that has it’s indexPath.row equal to TEST ?
Here is how i try to access the method(from the accelerometer function) but it gives me an error :
- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration
{
if(acceleration.x>0.5)
TEST++;
if(TEST<0) TEST=0;
if(TEST>19) TEST=19;
NSIndexPath *temp = [[NSIndexPath alloc] initWithIndex:TEST];
[self tableView:[self tableView] didSelectRowAtIndexPath:temp];
}
I have 20 rows in my table (hence the clamp).
selectRowAtIndexPath:animated:scrollPosition:
Selects a row in the receiver identified by index path, optionally scrolling the row to a location in the receiver.
Parameters
indexPath
An index path identifying a row in the receiver.
animated
YES if you want to animate the selection and any change in position, NO if the change should be immediate.
scrollPosition
A constant that identifies a relative position in the receiving table view (top, middle, bottom) for the row when scrolling concludes. See “Table View Scroll Position”
here