Frage

I have a toolbar button

UIBarButtonItem *systemItem2 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSearch target:self action:@selector(pressButton2:)];
    systemItem2.style = UIBarButtonItemStyleBordered;

and a press action

- (void) pressButton2:(id)sender{
        mapSearch.hidden = NO;
}

in viewWillAppear

- (void)viewWillAppear:(BOOL)animated
{
  mapSearch.hidden = YES;
}

How can I show and hide searchbar with same button (second press)?

War es hilfreich?

Lösung

I understand you would like to toggle the mapSearch.hidden. Here is a solution

mapSearch.hidden = !mapSearch.hidden;

or

mapSearch.hidden = (mapSearch.hidden) ? NO : YES;
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top