tags:

views:

264

answers:

1

how can i detect touch on already selected UIBarButtonItem? if i touch UIBarButtonItem , it will be selected..but if i touch the same again, how can i identify it ? any help please?

the code is as follows.. initWithCustomView:sortToggle in which sortToggle is segmented control...

 UIBarButtonItem *sortToggleButtonItem = [[UIBarButtonItem alloc] 
                                         initWithCustomView:sortToggle];
 [sortToggle release];

 UIBarButtonItem *flexibleSpaceButtonItem = [[UIBarButtonItem alloc] 
                  initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace 
                                       target:nil
                                       action:nil];

 NSArray *buttonArray = [NSArrayarrayWithObjects:flexibleSpaceButtonItem, 
                                                 sortToggleButtonItem, 
                                                 flexibleSpaceButtonItem, nil];

 [self setToolbarItems: buttonArray animated:YES];
A: 

The UIBarButtonItem does not inherit from the UIResponder so you can not get touchesBegan / touchedEnded etc events directly. If you set the UISegmentedControl to be momentary (yourSegControl.momentary = YES) you can select a button more than once. Is this helpful for your situation?

Otherwise, you should probably subclass the UISegmentedControl (which inherits from the UIResponder) and handle the extra touches yourself (don't forget to call super in any touch method you override).

Dimitris
any tutorial sir..?to handle it..?please..?
Mikhail Naimy
Did you try setting the .momentary property to YES?
Dimitris