我有一个 UIViewController 和一个 UIScrollView。由于我必须向视图控制器添加多个视图,而滚动视图只是其中之一,因此我尝试将控制器的视图设置为虚拟 UIView 并将滚动设置为子视图,如下所示:
[self setView:[[UIView alloc] initWithFrame:CGRectMake(0, 0, 1024, 768)]];
[[self view] setUserInteractionEnabled:NO];
// TDHexMapScrollView inherits from UIViewController
[self setHexMapScrollView:[[TDHexMapScrollView alloc] initWithFrame:CGRectMake(0, 0, 1024, 768)]];
[[self view] addSubview:[self hexMapScrollView]];
这样滚动不起作用。将其添加为主视图可以使滚动和平移正常工作:
[self setHexMapScrollView:[[TDHexMapScrollView alloc] initWithFrame:CGRectMake(0, 0, 1024, 768)]];
[self setView:[self hexMapScrollView]];
有什么帮助吗?谢谢