我有一个使用外部显示器的应用程序。
我在iPad上具有真实的表格视图,而在外部屏幕上具有镜像表格视图。
现在,我正在使用NSNotification
center来通知外部视图中的表它必须滚动,但是滚动非常粗糙,视觉上没有滞后感。
我该如何提高其性能?如何使它光滑和性感?
是的,两个TableView具有不同的大小。
这是我的代码:
控制器带实数UITableView
:
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
if (scrollView == self.iboTable)
[[NSNotificationCenter defaultCenter] postNotificationName:@"remoteControlTableScrolled" object:scrollView];
}
以及外部屏幕上的控制器:
- (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];
}
}
在此行发现了一个问题:
[self.iboTable setContentOffset:CGPointMake(notificationTableView.contentOffset.x,notificationTableView.contentOffset.y)animated:YES];
动画:否;
动画会导致滞后而不是平滑滚动,因为该动画用于一次动画滚动,例如直到第10个元素!
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句