首批推出我的应用程序后,我想向用户显示一个小教程,来解释我的应用程序的功能。
所以我需要设置一个transpalent的UIImageView一些箭头和标签,其中主UI(更多specificly,tableviewcontroller在navigationviewcontroller在tabbarcontroler)是教程图像背后STIL可见。
而且,因为教程由几个画面,我想补充轻拍姿态,将切换到另一个图像。
我想只是一个的UIImageView添加到我的tabbarcontroller,并和d一gesturerecogniser到这一点,但它并没有给我的自来水的,它只是工作,就像如果没有ImageView的反应 - 选择在表中的净资产收益率,推按钮。
-(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];
}
EDITED! 现在也应该努力在你的情况。
刚刚尝试添加标签bar.This可能工作fine.I不明白你的主要需求后添加图像视图到主屏幕,