如何显示全屏模式视图,然后如果用户触摸视图上的任何位置,该视图将自行删除。
you can present a modal view that has a custom button as the background, and then when you press the button, or "background", you can call [self dismissModalViewControllerAnimated:YES];
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
if ([touch view] == self) {
if ([touch tapCount] == 2) {
/* 2 touches here, you can dismiss your view */
}
}
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
if ([touch view] == self) {
if ([touch tapCount] == 1) {
/* 1 touch, dismiss your view */
}
}
If you were doing this inside of a subclass of UIViewController you could do something like this. This would trigger the modal to appear when the view is initially loaded, and trigger the modal to disappear when the screen is tapped.
-(void) viewDidLoad{
UIViewController *modalViewController = [[UIViewController alloc] init];
[modalViewController addTarget:self action:@selector(_dismissModal) forControlEvents:UIControlEventTouchUpInside];
[self presentModalViewController:modalViewController animated:YES];
}
-(void)_dismissModal{
[self dismissModalViewControllerAnimated:YES];
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.