所有UI前面的透明UIImageView

第一次启动我的应用程序后,我想向用户展示一个小教程,以解释我的应用程序的function。

所以我需要设置一个透明的UIImageView有一些箭头和标签,其中主要的用户界面(更具体地说,在tabbarcontroler navigationviewcontroller中的tableviewcontroller)在教程图像后面仍然可见。

而且,由于教程由多个图像组成,我想添加一个轻敲手势,将切换到另一个图像。

我只是试图添加一个UIImageView到我的tabbarcontroller,并为此添加了一个手势识别器,但是它不会对我的水龙头做出反应,它只是起作用,就像没有ImageView – select表中的鱼子一样,按下button。

-(void)nextTap:(UIGestureRecognizer*)nextTap { //Show another image } -(void)showTutorial { NSLog(@"Show tutorial"); UIImageView *tutorialImage = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"BG"]]; [self.navigationController.tabBarController.view addSubview:tutorialImage]; UITapGestureRecognizer *nextTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(nextTap:)]; [tutorialImage addGestureRecognizer:nextTap]; } 

有谁可以告诉我,我应该在哪里添加我的视图,而不是为了正常工作?

你应该设置tutorialImage.userInteractionEnabled = YES UIImageView的userInteractionEnabled属性的默认值是NO,它阻止UIImageView接收任何触摸事件,甚至手势

用另一个UIWindow来做!

喜欢这个:

 -(void)showTutorial { NSLog(@"Show tutorial"); CGRect screenBounds = [UIScreen mainScreen].bounds; UIWindow *anotherWindow = [[UIWindow alloc] initWithFrame:CGRectMake(0, 0, screenBounds.size.width, screenBounds.size.height)]; anotherWindow.windowLevel = UIWindowLevelAlert+1; [anotherWindow makeKeyAndVisible]; // make the background of the new window black alpha 0.5 anotherWindow.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5]; // add a test-image (icon) UIImageView *image = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon.png"]]; [anotherWindow addSubview:image]; UIImageView *tutorialImage = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"BG"]]; [anotherWindow addSubview:tutorialImage]; UITapGestureRecognizer *nextTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(nextTap:)]; [tutorialImage addGestureRecognizer:nextTap]; } 

编辑 ! 现在它应该也适用于你的情况。

只是尝试添加标签栏后,将图像视图添加到主屏幕。这可能工作得很好。我不明白你的主要要求,