ios - 使用第二个 UITableView 滚动 UITableView

标签 ios objective-c ipad uitableview uiscrollview

我有一个使用外部显示器的应用程序。

我在 iPad 上有真实的表格 View ,在外部屏幕上有镜像表格 View 。

现在,我正在使用 NSNotification center 来通知外部 View 上的表它必须滚动,但是滚动非常粗糙,视觉上没有延迟。

我怎样才能提高它的性能?如何让它既光滑又性感?

是的,两个 TableView 的大小不同。

这是我的代码:

带有真实 UITableView 的 Controller :

 - (void)scrollViewDidScroll:(UIScrollView *)scrollView 
   {
       if (scrollView == self.iboTable)
           [[NSNotificationCenter defaultCenter]    postNotificationName:@"remoteControlTableScrolled" object:scrollView];
    }

以及外接屏幕上的 Controller :

- (void)TableScrolled:(NSNotification *) notification
{
    UITableView *notificationTableView = notification.object;
    if(notificationTableView.contentOffset.y>self.iboTable.contentSize.height - self.iboTable.bounds.size.height) 
    {
        CGFloat yOffset = 0;
        yOffset = self.iboTable.contentSize.height - self.iboTable.bounds.size.height;

        [self.iboTable setContentOffset:CGPointMake(0, yOffset) animated:YES];
    }
    else if(notificationTableView.contentOffset.y + notificationTableView.frame.size.height == notificationTableView.contentSize.height)
    {
        [self.iboTable scrollRectToVisible:CGRectMake(0, self.iboTable.contentSize.height - self.iboTable.bounds.size.height, self.iboTable.bounds.size.width, self.iboTable.bounds.size.height) animated:YES];
    }
    else
    {
        [self.iboTable setContentOffset:CGPointMake(notificationTableView.contentOffset.x,notificationTableView.contentOffset.y)animated:YES];
    }
}

最佳答案

通知是一种笨拙的机制,可以在如此短的时间内发布如此多的通知。

在主屏幕 View Controller 中引用外部屏幕 View Controller ,并在 scrollViewDidScroll: 中相应地设置内容偏移量。

关于ios - 使用第二个 UITableView 滚动 UITableView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24695879/

相关文章:

ios - ShareKit 导致我的 iOS 应用程序崩溃?

ios - 有没有办法手动更改 PDF 的 url 路径并使其实时更新?

iOS Safari 显示已安装的应用程序。这是如何运作的?元标签?

ios - 将存储在 NSMutableArray 中的多个 UIImage 转换为 PDF

objective-c - 如何完全删除手势识别器

ios - Facebook 登录问题 iOS9 + Parse

iphone - iOS 初学者 : NSMutableArray + int variable for storing array index position (Where is the connection)

ios - 顶部导航无法正常显示 - iPhone 应用程序也必须在 iPhone 分辨率和 2X iPhone 3GS 分辨率下未经修改地在 iPad 上运行

iphone - 可定制的 iOS 消息编辑器

iphone - 即时创建 *.docx(也许还有 *.doc?)文档?