gpt4 book ai didi

ios - 使用第二个 UITableView 滚动 UITableView

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:38:56 25 4
gpt4 key购买 nike

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

我在 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com