A really simple question here. How do you create a view like this?
It has to overlay the first time user runs this part of the app and be removed forever once the user taps on it. I understand it should be a UIImageView, but how do you make it active and then remove it from the view forever?
You can add your subview just after your app launch in the didFinishLaunchingWithOptions
method of your app delegate by using the addSubView
method of the UIView
class. Here are some code snippets of how you could proceed:
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
UIImageView *imageView = [[UIImageView alloc]
initWithImage:[UIImage imageNamed:@"yourimage.png"]];
[self.window addSubview:imageView];
UITapGestureRecognizer * recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
recognizer.delegate = self;
[imageView addGestureRecognizer:recognizer];
imageView.userInteractionEnabled = YES;
self.imageView = imageView;
}
- (void) handleTap:(UITapGestureRecognizer *)recognize
{
[self.imageView removeFromSuperView];
}
Note that you will need a property to reference your imageView in the handleTap
method.
UIView
has all the methods you need, e.g.
[myView addSubview:imgView]
to add the image view to the current view (myView
)[imgView removeFromSuperview]
when finish (i.e. in respond to tap or after a timer)Make sure userInteractionEnabled
property of imgView
to NO
so that touches are passed to myView
.
My thoughts would be set an NSUserDefault variable and check it on applicationDidFinishLaunchingWithOptions or somewhere else in your app that makes sense. You could just push a separate view when your variable is true vs. false.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With