2013-02-10 129 views
3

我在想如何将图像添加到应用程序,该应用程序覆盖了整个屏幕与应用程序本身的信息。在第一次启动iPhone应用程序时显示信息imageview

这是要求:

  • 只有在第一次启动
  • 覆盖整个屏幕显示一次(包括的TabBar和导航栏)
  • 当图像用户点击,就应该消失,并不会出现再次;)

例(只发现一个在iPad上,但我需要它为iPhone):

enter image description here

我该怎么做?有没有我可以使用的免费框架?任何提示,信息或链接非常感谢。

+1

@ H2CO3,如果仔细阅读,它不是真的重复! – doonot 2013-02-10 11:38:35

+0

事实上,这不是重复的。 – Koen 2016-04-24 20:36:45

回答

6
  1. 检查NSUserDefaults的,如果被显示的帮助视图(和解雇)之前
  2. 创建的UIImageView并将其添加到您的视图
  3. 添加UITapGestureRecognizer到图像查看
  4. 在轻击手势的操作中删除帮助视图并保存到NSUserDefaults视图已被解散。

- (void)viewDidLoad { 
    [super viewDidLoad]; 
    if (![[NSUserDefaults standardUserDefaults] boolForKey:@"didDisplayHelpScreen"]) { 
     UIWindow *window = [[[UIApplication sharedApplication] windows] lastObject]; 

     UIImageView *imageView = [[UIImageView alloc] initWithFrame:window.bounds]; 
     imageView.image = [UIImage imageNamed:@"78-stopwatch"]; 
     imageView.backgroundColor = [UIColor greenColor]; 
     imageView.alpha = 0.5; 
     UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissHelpView:)]; 
     [imageView addGestureRecognizer:tapGesture]; 
     imageView.userInteractionEnabled = YES; 
     [window addSubview:imageView]; 
    } 
} 

- (void)dismissHelpView:(UITapGestureRecognizer *)sender { 
    UIView *helpImageView = sender.view; 
    [helpImageView removeFromSuperview]; 
    [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"didDisplayHelpScreen"]; 
} 
+0

非常感谢你,正是我所需要的。但图像视图不包括导航栏和Tabbar。任何想法? – doonot 2013-02-10 12:04:26

+0

我做了一个编辑。将imageView添加到窗口应该可以工作。 – 2013-02-10 12:27:53

+0

非常感谢Matthias,按预期工作! – doonot 2013-02-10 12:33:49

3

在NSUserDefaults中定义一些BOOL键。如果不是,则显示您的覆盖图并将其设置为YES。下次用户启动应用程序时,此步骤将被跳过。

要添加图像来覆盖你的观点,代码将是这个样子:

UIImageView *imageView = [[UIImageView alloc] initWithFrame:self.view.frame]; 
imageView.image = [UIImage imageNamed:@"overlay image"]; 
[self.view addSubview:imageView]; 
+0

好提示,thx。在整个屏幕上设置UIImageView怎么样? – doonot 2013-02-10 11:34:54

相关问题