how to dismiss action sheet with a custom button

只愿长相守 提交于 2019-12-11 05:02:25

问题


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];

回答1:


in dismissActionSheet method write

[aSheet dismissWithClickedButtonIndex:0 animated:YES];



回答2:


Implement the delegate <UIActionSheetDelegate>. and paste the following code in button click event.

[actionSheet dismissWithClickedButtonIndex:0 animated:YES];



回答3:


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.




回答4:


Implement the UIActionSheetdelegate protocol and you will be good to go. Specifically actionSheet:clickedButtonAtIndex: .



来源:https://stackoverflow.com/questions/6775235/how-to-dismiss-action-sheet-with-a-custom-button

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!