Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UINavigationBar Touch

Tags:

I would like to fire an event on touch when a user taps the title of the navigation bar of one of my views.

I'm at a bit of a loss on whether I can access the view of the title of the UINavigationBar in order to wire up a touch event to it.

Is this even possible?

like image 673
mootymoots Avatar asked Jan 16 '10 10:01

mootymoots


People also ask

Apa fungsi dari navigation bar?

Navbar tersebut disusun sesuai dengan standar borang penilaian Akreditasi Program Studi BAN PT. NavBar berisi informasi yang memudahkan proses akreditasi dimana setiap standar dijadikan menu yang memudahkan sistem pengaksesan informasi secara online tanpa harus mengecek dokumen secara manual.

Apa Tombol Back?

Back button adalah aplikasi menarik yang berfungsi untuk menambahkan tombol kembali melayang di perangkat Android. Inilah opsi yang bagus jika tombol kembali fisik pada ponsel Anda rusak tetapi fitur-fitur...


1 Answers

You can add a gesture recognizer to be a single tap to the title of the navigation controller. I found that in the navigationBar subviews, the title is the one at index 1, the left button's index is 0 and the right button's index is 2.

UITapGestureRecognizer *navSingleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(navSingleTap)]; navSingleTap.numberOfTapsRequired = 1; [[self.navigationController.navigationBar.subviews objectAtIndex:1] setUserInteractionEnabled:YES]; [[self.navigationController.navigationBar.subviews objectAtIndex:1] addGestureRecognizer:navSingleTap]; 

and then implement the following somewhere in your implementation.

-(void)navSingleTap 

So you can use this for a single tap, or you can implement any gesture recognizer you want on that title.

like image 156
phmagic Avatar answered Sep 19 '22 14:09

phmagic