In my app I tried to push to a XIB using a long tap
event. I did the following code,
In viewDidLoad
UILongPressGestureRecognizer *longPress = [[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPress:)]autorelease];
longPress.delegate = (id<UIGestureRecognizerDelegate>)self;
[self.view addGestureRecognizer:longPress];
[longPress requireGestureRecognizerToFail:doubleTap];
and longPress method is
- (void)longPress:(UILongPressGestureRecognizer*)gesture {
if ( gesture.state == UIGestureRecognizerStateEnded ) {
ProductDetailViewController *vc = [[[ProductDetailViewController alloc] initWithNibName:@"ProductDetailViewController" bundle:nil] autorelease];
[self.navigationController pushViewController:vc animated:YES];
NSLog(@"Long Press");
}
}
I have a XIB named ProductDetails.xib
and I set the File's Owner
of it as ProductDetailViewController
.
When I'm running this code NSLog
is working. But it's not going to the ProductDetails.h
. And also There are no errors. How can I fix this? Anyone can help me with this.
Thanks in Advance!
You already have the xib hooked up to the controller, you can achieve that with the following.
ProductDetailViewController *vc = [[[ProductDetailViewController alloc] init] autorelease];
[self.navigationController pushViewController:vc animated:YES];