我有一个名为SplashViewController的UIViewController实例。我将其添加到AppDelegate的主窗口中,如下所示:
splashViewController = [[SplashViewController alloc]initWithNibName:@"SplashScreen" bundle:[NSBundle mainBundle]];
splashViewController.view.frame = [UIScreen mainScreen].bounds;
[self.window setBackgroundColor:[UIColor blackColor]];
self.window.frame=[UIScreen mainScreen].bounds;
window.rootViewController = splashViewController;
[window makeKeyAndVisible];我必须在SplashViewController中处理触摸事件,并且我需要在程序中将userInteractionEnabled设置为YES和NO。由于某些原因,我下面的代码没有效果
[self.view setUserInteractionEnabled:NO]; // YES also have no effect无论我在上面设置了YES或no,总是触发我的touchesBegan函数。SplashViewController有一个图像视图,里面有一个图像和一个简单的动画。
我还能在哪里找到userInteraction没有按照我想要的方式运行的原因?我尝试更改Storyboard中设置的值,但没有帮助(我猜,无论如何程序设置应该覆盖Storyboard设置)。
提前提供任何帮助/指针please...Thanks
发布于 2013-09-08 10:49:26
尝试设置:
self.view.userInteractionEnabled = YES;在SplashViewController对象的"viewWillAppear:“方法中。
另外,您是否将"splashViewController“作为实例变量保存在您的应用程序委托中?在AppDelegate的.h或.m文件中,在哪里声明"SplashViewController * splashViewController;“?如果它没有在你的应用代理中被设置为ivar,那么它很可能是在你添加它之后立即发布的。
https://stackoverflow.com/questions/18679885
复制相似问题