Ios 启动屏幕后奇怪的UISCrollView行为
一个UISCrollview发生了一些奇怪的事情 我的方案是MainView->ScrollView->ViewScrollView 在 应用程序加载,scrollview工作正常完全没有问题。 我遇到的唯一问题是应用程序第一次运行。 它需要下载一些巨大的文件来为ipad的sqlite数据库提供数据,速度可能非常慢,(需要下载大约10Mb),所以我创建了一个启动屏幕,显示需要多长时间,下载了多少,等等 如代码所示,我将其加载为[self showSplash]Ios 启动屏幕后奇怪的UISCrollView行为,ios,uiscrollview,splash-screen,Ios,Uiscrollview,Splash Screen,一个UISCrollview发生了一些奇怪的事情 我的方案是MainView->ScrollView->ViewScrollView 在 应用程序加载,scrollview工作正常完全没有问题。 我遇到的唯一问题是应用程序第一次运行。 它需要下载一些巨大的文件来为ipad的sqlite数据库提供数据,速度可能非常慢,(需要下载大约10Mb),所以我创建了一个启动屏幕,显示需要多长时间,下载了多少,等等 如代码所示,我将其加载为[self showSplash] #pragma mark spla
#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];
}
它会按应显示splashScreen并开始下载
- (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不会滚动
这是我在splashScreen关闭后调用的“ViewDidDisplay”结尾处得到的日志文件。
(如果我第二次运行应用程序时未出现启动屏幕,则完全相同)
在不加载溅屏的情况下,它可以工作,加载后则无法工作
有人知道发生了什么事吗?我终于解决了。这是我在XCode中见过的最奇怪的事情 在这个应用程序中,我有很多使用故事板分段的模式视图,当我返回主视图时,scrollview工作得非常完美,所以我尝试用分段来显示splashscreen,而不是对其进行编码,还有,神奇!成功了 深入研究代码,我发现
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];
segue方法是:modalPresentationStyle
在IDE上,我选择了“页面工作表”,并以代码方式使用UIModalPresentationFullScreen
因此,将所有代码还原到我在这里提出问题的那一刻,并进行更改
[sfvc setModalPresentationStyle:UIModalPresentationFullScreen];
为了
scrollview又完美地工作了
谁能解释一下为什么会这样?可能是一个错误?其他触摸事件是否响应,只是没有滚动?能否显示您在何处定义sfvc.delegate的属性?最后,您是否已验证MBProgressHUD已成功删除?(我认为它会阻止触摸事件。)触摸事件会做出响应,我尝试不显示这个复杂的启动屏幕,而是显示一个空视图,并在1秒后将其关闭。我也有同样的问题。所以AFAIK MDProgressHUD没有参与。也许,我没有以正确的方式显示启动屏幕吗?我测试过的另一件事是,不要在ViewDiApper中加载splashscreen,而是在按钮中加载它。在我按下按钮之前,scrollview工作,在显示/隐藏splashscreen之后,它不工作。。。。真奇怪。。。
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];
[sfvc setModalPresentationStyle:UIModalPresentationFullScreen];
[sfvc setModalPresentationStyle:UIModalPresentationPageSheet];