如何使用自定义按钮关闭操作表
我在操作表上创建了两个按钮和一个日期选择器。单击完成按钮后,我想关闭操作表。任何人都可以帮助编写用于关闭操作表的代码吗?
我使用此代码为“完成”按钮提供操作:
[doneButton addTarget:self action:@selector(dismissActionSheet:) forControlEvents:UIControlEventValueChanged];
I created two buttons and one date picker on the action sheet.On clicking the done button i want to dismiss the action sheet.Can anyone please help with the code for dismissing the action sheet.
i'm using this code for giving action for done button:
[doneButton addTarget:self action:@selector(dismissActionSheet:) forControlEvents:UIControlEventValueChanged];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
实现委托
。并将以下代码粘贴到按钮单击事件中。Implement the delegate
<UIActionSheetDelegate>
. and paste the following code in button click event.在dismissActionSheet方法中写入
in dismissActionSheet method write
您需要保留一个指向您的actionSheet的实例变量,并且在您的
dismissActionSheet:
函数中只需编写[actionSheet解雇WithClickedButtonIndex:0动画:YES];
。应该可以做到这一点。You need to keep an instance variable that points to your actionSheet and than in your
dismissActionSheet:
function just write[actionSheet dismissWithClickedButtonIndex:0 animated:YES];
. That should do it.实现 UIActionSheetdelegate 协议,你就可以开始了。具体来说是
actionSheet:clickedButtonAtIndex:
。Implement the UIActionSheetdelegate protocol and you will be good to go. Specifically
actionSheet:clickedButtonAtIndex:
.