iphone - Custom behavior when "back" button in nav bar pressed -
i know can add custom "back" button uinavigationbar, doing removes existing button tapered left side, described in what happens when button pressed in navigationbar
is there way keep existing behavior , of button, informed when pressed?
basically, want app play sound whenever button touched. can uitabbarcontroller via delegate, delegate uinavgationbarcontroller has no such functionality.
the following possibilities view controller disappear.
- clicking on button (other backbarbuttonitem).
- clicking on backbarbuttonitem
either case viewwilldisappear: method called. keep boolean flag. lets name isanybuttonclicked. , set isanybuttonclicked = yes whenever button clicked. , override viewwilldisappear: method, , play sound if no button clicked(ie., isanybuttonclicked == no). viewwilldisappear: like,
- (void)viewwilldisappear:(bool)animated { [super viewwilldisappear:animated]; if (!isanybuttonclicked) { // play sound isanybuttonclicked = no; } }
Comments
Post a Comment