-1
我想知道如何使用子视图UILabel访问UIScrollView。programigaclly滚动UIScrollView使用子视图元素
我曾尝试使用.superview访问的UIScrollView但是我现在reciving
No visible @interface for 'UIView' declares the selector 'scrollRectToVisible:animated:'
的代码我使用看起来像这样
- (void) SymbolButtonPressed:(NSString *)selectedString {
UILabel *label = (UILabel *)[self.view viewWithTag:currentlySelectedTag];
// perform scrolling here, figure out what view your uilable is in.
float newPosition = label.superview.contentOffset.x+label.frame.size.width;
CGRect toVisible = CGRectMake(newPosition, 0, label.superview.frame.size.width, label.superview.frame.size.height);
[label.superview scrollRectToVisible:toVisible animated:YES];
}
任何帮助,将不胜感激错误。
的XCode dosnt这样的代码。看起来我必须找到另一种方式来访问它。它的理由是我有多个UILabels里面放置在UITableViewCells内的多个滚动视图。所以我有一个UIScrollviews作为它们的单元格的表,并试图找出哪个UIScroll视图滚动。 – HurkNburkS
@HurkNburkS我已经扩展了我的答案,包括将superview投射到UIScrollView - 这可能是Xcode抱怨的。试试看。 – Matt