如何显示全屏模式视图,然后如果用户触摸视图上的任何位置,该视图将自行删除。
最佳答案
您可以显示一个以自定义按钮为背景的模式视图,然后当您按下按钮或“背景”时,可以调用[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 */
}
}
关于iphone - 打开模态视图并在iPhone上关闭,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/4475152/