Reputation: 11
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]; `
Upvotes: 1
Views: 6617
Reputation: 14995
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.
Upvotes: 0
Reputation: 45490
You need to point to the UItableView
[self.tableView scrollToRowAtIndexPath:newIndexPath
atScrollPosition:UITableViewScrollPositionTop
animated:NO];
Upvotes: 2
Reputation: 769
You just need to call is self.tableView instead of self. self refers to the TableViewController and self.tableView to it's tableView.
Upvotes: 0