2013-02-10 66 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

相關問題