简体   繁体   English

在iPhone上显示UIActionView后,取消按钮单击突出显示

[英]Cancel button click highlight after showing UIActionView on iphone

I have a view that has a button which brings up a UIActionSheet pop up on click. 我有一个带有按钮的视图,该按钮在单击时弹出一个UIActionSheet。 If the user clicks cancel, the original button that brought up the action sheet is still highlighted as if it is being clicked. 如果用户单击“取消”,则提起操作表的原始按钮仍会被高亮显示,就像被单击一样。 How do I reset the state after user cancels the action? 用户取消操作后如何重置状态?

Use one of the protocol methods to change the state of the button that was clicked: 使用协议方法之一来更改单击的按钮的状态:

@protocol UIActionSheetDelegate <NSObject>
@optional

// Called when a button is clicked. The view will be automatically dismissed after this call returns
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex;

// Called when we cancel a view (eg. the user clicks the Home button). This is not called when the user clicks the cancel button.
// If not defined in the delegate, we simulate a click in the cancel button
- (void)actionSheetCancel:(UIActionSheet *)actionSheet;

- (void)willPresentActionSheet:(UIActionSheet *)actionSheet;  // before animation and showing view
- (void)didPresentActionSheet:(UIActionSheet *)actionSheet;  // after animation

- (void)actionSheet:(UIActionSheet *)actionSheet willDismissWithButtonIndex:(NSInteger)buttonIndex; // before animation and hiding view
- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex;  // after animation

@end

Sorry about my false assumption that you were using UIButton. 对不起我对您使用的是UIButton的错误假设。 Here should be what you need: 这应该是您需要的:

- (void)tableView:(UITableView *)tableView 
didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    //your implementation here
    ....

    //Then deselect the row so it quits the highlighted state
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM