IOS 7 如何使用 UITableView scrollToRowAtIndexPath [英] IOS 7 how to use UITableView scrollToRowAtIndexPath

查看:24
本文介绍了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];

这篇关于IOS 7 如何使用 UITableView scrollToRowAtIndexPath的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆