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

时间:2011-01-05 00:59:15

标签: iphone objective-c

我有一个视图,它有一个按钮,可以在点击时弹出一个UIActionSheet。如果用户单击取消,则仍会突出显示启动操作表的原始按钮,就像单击该按钮一样。用户取消操作后如何重置状态?

2 个答案:

答案 0 :(得分:1)

使用其中一种协议方法更改所单击按钮的状态:

@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

答案 1 :(得分:0)

很抱歉我误以为您使用的是UIButton。这应该是你需要的:

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