1
votes

I'm new to IOS 7 and I'm made a test application where I want to use scrollToRowAtIndexPath when a left swipe is detected. The swipe is detected but I'm struggling with the "self" definition. I get the error No visible @interface for 'SimpleTableViewController'

- (void)handleSwipeLeft:(UISwipeGestureRecognizer *)recognizer
{
    NSLog(@"%u = %d",  recognizer.direction,recognizer.state);

     // jump to section 0 row 20 when leftswipe is dectected
    NSIndexPath *newIndexPath = [NSIndexPath indexPathForRow:20 inSection:0];

    [self.tableView scrollToRowAtIndexPath:newIndexPath atScrollPosition:UITableViewScrollPositionTop animated:NO];

}

I can send the complete source code if you want or you can download it here:

www.auditext.com/xintax/SimpleTable.zip

Using self.tableView gives message Property 'tableView' not found on object of type 'SimpleTableViewController' –

It works now I have added this line to my viewcontroller.h: `@property (strong, nonatomic) IBOutlet UITableView *myview;

NSIndexPath *loc = [NSIndexPath indexPathForRow:row inSection:section];

[self.myview scrollToRowAtIndexPath:loc atScrollPosition:UITableViewScrollPositionBottom animated:YES]; `

3
Post the code that is actually giving you the error and point out the exact line causing the problem.rmaddy
And include the complete error message.rmaddy
Where is this code? Is this in the code of a custom table view cell class or in the code for your view controller?rmaddy
@user3369041, You need to declare property of UITableView in your header file. Check my updated answer below.Hussain Shabbir

3 Answers

2
votes

You need to point to the UItableView

[self.tableView scrollToRowAtIndexPath:newIndexPath 
                      atScrollPosition:UITableViewScrollPositionTop 
                              animated:NO];

enter image description here

0
votes

You just need to call is self.tableView instead of self. self refers to the TableViewController and self.tableView to it's tableView.

0
votes

Why you are getting this error, Because scrollToRowAtIndexPath is a UITableView method Refer this.

And also you are calling the same method with self which indicate you class name SimpleTableViewController. So you are getting this error No visible @interface for 'SimpleTableViewController'. Just call this method with self.tableView instead of using self.

Note:-

1) Declare property inside your header file SimpleTableViewController @property(nonatomic,strong)UITableView *tableView

2) No need to explicitly include the synthesize, if you are using Xcode version above than 4.