我对此还是很陌生,所以请耐心等待。我认为我可以在 ScrollView 中加载 Xib,因为我已经看到似乎可以执行此操作的应用程序,但我们正在谈论两个不同的类。但无论如何我会问 - 是否有任何实用的方法可以让滚动视图在顶部带有静态 Xib,其中 UI 中定义的按钮不会移动,而下面的视图会移动。我确信它在 cocos2d 中很容易实现,但是对于我想做的事情来说,这有点矫枉过正。
- - 编辑 - -
冒着让自己尴尬的风险,我尝试了两种可能的解决方案。添加一个按钮在语法上添加了一个在我滚动时移动的按钮。添加笔尖似乎可以防止滚动屏幕滚动。这是代码,无需尝试添加任何按钮,一切正常。
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
NSLog(@"View Loaded");
[mdm setMapSetupInfoWithRows:60 columns:90 cellSize:32];
[mdm initMapDataWithOriginsUsingCenter:TRUE];
NSLog(@"MapViewContoller.mapArrayCount = %d",[[mdm mapArray]count]);
// create the MapView with the screen size create by MapDataManager
mapView = [[MapView alloc] initWithFrame:[mdm mapRect]];
// Create the UIScrollView to have the size of the window, matching the window (screen) size
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:[mdm windowRect]];
[scrollView setBounds:[mdm windowRect]];
// Tell the scrollview how big it is and set other options
[scrollView setContentSize:[mdm mapRect].size];
[scrollView setBounces:NO];
[scrollView setMinimumZoomScale:.5];
[scrollView setMaximumZoomScale:10];
[scrollView setDelegate:self];
[scrollView setBackgroundColor:[UIColor darkGrayColor]];
//add the MapView as a subview of the scrollView
[scrollView addSubview:mapView];
//add the scrollView to the current one....
[[self view] addSubview:scrollView];
[[NSBundle mainBundle] loadNibNamed:@"MapViewController" owner:self options:nil];
[self generNewMap];
}
还有什么我想做错的吗?在看了这个之后,它似乎确实可行。