2
votes

I created a custom navigation back button. But when I add this code, my back animation doesn't work and it goes back with animation. Why? I think it depends on my @selector action.

- (void)viewDidLoad {


    UIButton *button =  [UIButton buttonWithType:UIButtonTypeCustom];
    [button setImage:[UIImage imageNamed:@"goback.png"] forState:UIControlStateNormal];
    [button addTarget:self action:@selector(//HERE ! i don't know put what thing !) forControlEvents:UIControlEventTouchUpInside];
    [button setFrame:CGRectMake(0, 0, 32, 32)];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
}
1
just a note... No need to write self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button]; you can directly write self.navigationItem.leftBarButtonItem = buttonMihir Mehta

1 Answers

3
votes

ok i created a function and works fine :D :

-(void)pushNav {
[self.navigationController popViewControllerAnimated:YES];  
}