IOS 7 如何使用 UITableView scrollToRowAtIndexPath

问题描述:

我是 IOS 7 的新手,我制作了一个测试应用程序,我想在检测到向左滑动时使用 scrollToRowAtIndexPath.检测到滑动,但我正在努力解决自我"定义.我收到错误 No visible @interface for 'SimpleTableViewController'

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

www.auditext.com/xintax/SimpleTable.zip

使用 self.tableView 会在SimpleTableViewController"类型的对象上提供消息属性tableView"未找到 –

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

它现在可以工作了,我已将此行添加到我的 viewcontroller.h 中:`@property(强,非原子)IBOutlet UITableView *myview;

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];

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

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

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

需要指向UItableView

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