gpt4 book ai didi

iphone - 在 iPhone 上打开模态视图并关闭

转载 作者:行者123 更新时间:2023-11-28 17:47:46 25 4
gpt4 key购买 nike

如何显示全屏模态视图,然后如果用户触摸 View 上的任何位置, View 将自行删除。

最佳答案

你可以呈现一个模态视图,它有一个自定义按钮作为背景,然后当你按下按钮或“背景”时,你可以调用[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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com