一个 UISCrollview 发生了一些奇怪的事情。
我的方案是 MainView -> ScrollView -> ViewScrollView
在
- (void)viewDidAppear:(BOOL)animated{
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication]delegate];
if (appDelegate.first_time ) {
NSLog(@"First time.We need to feed sqlite.");
[self showSplash];
appDelegate.first_time = false;
}
_scrollView.contentSize = CGSizeMake(768*2, 870);
[_scrollView setScrollEnabled:YES];
... other stuff
}
应用程序加载并且滚动视图完美运行。完全没有问题。
我遇到的唯一问题是应用程序第一次运行。它需要下载一些大文件来提供 ipad 的 sqlite 数据库,它可能非常慢,(它必须下载大约 10Mb)所以我创建了一个启动屏幕,显示需要多长时间,下载了多少等。 ..
如代码所示,我将其加载为 [self showSplash];
#pragma mark splash screen
- (void)showSplash {
NSLog(@"showSplash");
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
modalSplashScreenViewController *sfvc = [storyboard instantiateViewControllerWithIdentifier:@"modalSplashScreenViewController"];
sfvc.delegate = (id)self;
[sfvc setModalPresentationStyle:UIModalPresentationFullScreen];
[self presentViewController:sfvc animated:NO completion:nil];
}
它按原样显示启动画面并开始下载
- (void)viewDidAppear:(BOOL)animated{
hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hud.mode = MBProgressHUDModeIndeterminate;
hud.dimBackground = YES;
hud.labelText = @"Loading";
hud.detailsLabelText = @"updating data";
hud.delegate = self;
[hud showWhileExecuting:@selector(feed_it) onTarget:self withObject:nil animated:YES];
}
- (void)feed_it{
// feeds sqlite
// when has finished closes the view.
[self dismissViewControllerAnimated:YES completion:nil];
}
隐藏启动画面后, UIScrollView 不会滚动。
这是我从“ViewDidAppear”末尾得到的日志文件,在 splashScreen 关闭后调用。(如果我第二次运行该应用程序而没有出现启动画面,则完全相同)
_viewScrollView frame width 1536.000000 frame origin.x 0.000000
_viewScrollView frame height 870.000000 frame origin.y 0.000000
_scrollview frame width 768.000000 frame origin.x 0.000000
_scrollview frame height 870.000000 frame origin.y 45.000000
_scrollView.contentSize.width 1536.000000 height:870.000000
_scrollView.contentOffset.x 0.000000 y:0.000000
_scrollView.bounds.size.width 768.000000 height 870.000000
_scrollView.intrinsicContentSize.width -1.000000
_scrollView.contentSize.width 1536.000000 height:870.000000
不加载启动画面就可以工作,加载后就不行。
有人知道发生了什么吗?