benim çözüm applicationDidFinishLaunchingWithOptions ise uygulamamda gezinme çubuğunda "sahibi"),:
nav çubuğu görünüm elde edin ve tüm görünümüne jest tanıyıcı ekleyin: appDel içinde Sonra
// Get the nav bar view
UINavigationBar *myNavBar = nil;
for (UIView *view in [self.window.rootViewController.view subviews]) {
if ([view isKindOfClass:[UINavigationBar class]]) {
NSLog(@"Found Nav Bar!!!");
myNavBar = (UINavigationBar *)view;
}
}
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self
action:@selector(backButtonLongPress:)];
[myNavBar addGestureRecognizer:longPress];
NSLog(@"Gesture Recognizer Added.");
egate, içinde - (void) backButtonLongPress: (id) gönderen
jest geri düğmesi çerçevesinde oluşursa kontrol edin: backButtomItem değil mi üzerine özel bir görünüm için jest tanıyıcı ekleme
if ([sender state] == UIGestureRecognizerStateBegan) {
// Get the nav bar view
UINavigationBar *myNavBar = nil;
for (UIView *view in [self.window.rootViewController.view subviews]) {
if ([view isKindOfClass:[UINavigationBar class]]) {
NSLog(@"Found Nav Bar!!!");
myNavBar = (UINavigationBar *)view;
}
}
// Get the back button view
UIView *backButtonView = nil;
for (UIView *view in [myNavBar subviews]) {
if ([[[view class] description] isEqualToString:@"UINavigationItemButtonView"]) {
backButtonView = view;
NSLog(@"Found It: %@", backButtonView);
NSLog(@"Back Button View Frame: %f, %f; %f, %f", backButtonView.frame.origin.x, backButtonView.frame.origin.y, backButtonView.frame.size.width, backButtonView.frame.size.height);
}
}
CGPoint longPressPoint = [sender locationInView:myNavBar];
NSLog(@"Touch is in back button: %@", CGRectContainsPoint(backButtonView.frame, longPressPoint) ? @"YES" : @"NO");
if (CGRectContainsPoint(backButtonView.frame, longPressPoint)) {
// Place your action here
}
// Do nothing if outside the back button frame
}
Benim için çalışıyorum ... tanıyıcı ateş etmeyi reddediyor. Yukarıdaki kodla çalışmayı başarabildiniz mi? – kevboh
Muhtemelen backBarButtonItem salt okunur olduğundan çalışmaz, bu yüzden özel bir görünüm kabul etmiyor.Muhtemelen bu cevap gibi kendi sol çubuğunuzda oluşturmalısınız. http://stackoverflow.com/questions/526520/how-to-create-backbarbuttomitem-with-custom-view-for-a-uinavigationcontroller – Andrew
Ah, ama sonra bir imge bulmazsam arka okumu kaybediyorum. Değmez. Yine de teşekkürler! – kevboh