gpt4 book ai didi

ios - 当我点击 ios 中的 View 时如何关闭 tableviewcell 中的操作表

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

这是我的代码。我对 Xcode 很陌生。当我点击 tableview 单元格时,我得到了 UIActionSheet。为了关闭 UIActionSheet,我使用了 UITapGestureRecognizer。它对我不起作用。

    - (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell = [aTableView cellForRowAtIndexPath:indexPath];
UILabel *lbl = (UILabel *)[cell.contentView viewWithTag:2];
NSLog(@"cell text label =%@",lbl.text);
_StoreNameobj = lbl.text;


UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Store Maintenance Action"
delegate:self
cancelButtonTitle:cancelTitle
destructiveButtonTitle:nil
otherButtonTitles:@"Show Store Details",@"Navigate to Store",@"Edit Store Nickname",@"Delete Store", nil];


actionSheet.userInteractionEnabled = YES;

UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapOut:)];
[lbl addGestureRecognizer:tapGesture];
[cell.contentView addSubview:lbl];
}

- (void)tapOut{
//dismiss the action sheet here
[actionSheet removeFromSuperview];
}

非常感谢您的帮助。在此先致谢!

最佳答案

我认为您不需要手动删除操作表。默认情况下,操作表会在单击时退出。我认为没有必要采取 Tab 手势。

像这样显示操作表

[actionSheet showInView:self.view];

所以当你点击任何按钮时它会自动消失

关于ios - 当我点击 ios 中的 View 时如何关闭 tableviewcell 中的操作表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36937581/

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