gpt4 book ai didi

iphone - 当用户点击 iPhone 中的上方 View 时隐藏 UIActionSheet

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:00:02 24 4
gpt4 key购买 nike

我想在操作表上设置操作,这样当用户点击操作表上方时它会被取消。
我想这样做是因为我不想在操作表中添加取消按钮。用户可以通过点击休息区 View 来取消操作表,而不是取消按钮。
关于如何在 iPhone 中执行此操作的任何建议。
谢谢

最佳答案

// For detecting taps outside of the alert view
-(void)tapOut:(UIGestureRecognizer *)gestureRecognizer
{
CGPoint p = [gestureRecognizer locationInView:self];
if (p.y < 0)
{ // They tapped outside
[self dismissWithClickedButtonIndex:0 animated:YES];
}
}

-(void) showFromTabBar:(UITabBar *)view
{
[super showFromTabBar:view];

// Capture taps outside the bounds of this alert view
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapOut:)];
tap.cancelsTouchesInView = NO; // So that legit taps on the table bubble up to the tableview
[self.superview addGestureRecognizer:tap];
[tap release];
}

参见 here .

请注意,这已经发生在 iPad 上。

关于iphone - 当用户点击 iPhone 中的上方 View 时隐藏 UIActionSheet,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8683752/

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