Puede agregar su subvista justo después del inicio de su aplicación en el método didFinishLaunchingWithOptions
de su delegado de la aplicación mediante el método addSubView
de la clase UIView
. Éstos son algunos fragmentos de código de cómo se podría proceder:
- (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];
}
Tenga en cuenta que se necesita una propiedad para hacer referencia a su imageView en el método handleTap
.
Gracias, hombre! Funciona como encanto! –
Obtuve "Asignando a 'id' del tipo incompatible 'AppDelegate *'" - ¿algún consejo? ¡Gracias! –
Ernest
necesita hacer que su AppDelegate cumpla con el UIGestureRecognizerDelegate al declarar algo como esto: yourAppDelegate() –
tiguero