2011-01-05 20 views
0

私は、クリックするとUIActionSheetのポップアップを表示するボタンを持つビューを持っています。ユーザーがキャンセルをクリックすると、アクションシートを持ってきた元のボタンは、クリックされているかのように強調表示されます。ユーザーがアクションをキャンセルした後、状態をリセットするにはどうすればよいですか?キャンセルボタンiPhoneでUIActionViewを表示した後にハイライトをクリックします。

答えて

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]; 
} 
+0

それはとてもうまくいった。私はUIActionSheetを表示する前に選択を解除していますが、UIActionSheetは行のハイライトを無効にするという作業ではなく、ユーザーにクリック感を即座に与えるので、私のケースでは完全に機能します。再度、感謝します。 –

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 
+0

ありがとうdiwup。しかし、私はボタンの "状態を変える"ことに困っています。特に、didDismissWithButtonIndexメソッドで設定する必要があるもの。 [UIButton resignFirstResponder]かそれとも何か? –

+0

UIActionSheetを起動する最初の「ボタン」は、実際はUItableviewcellであることを忘れていました。だから、私はその行の青い色を取り除く必要があります。 –

+0

@coder net:UIButtonはUIControlのサブクラスであり、UIControlは**(BOOL)という名前のプロパティを持っているので、UIButtonを使用したと仮定します**。私はあなたがあなたのアクションシートをキャンセルすると、そのプロパティを** NO **に戻すことができると思います。 –

関連する問題