Try changing your leftBarButtonItem
:
self.navigationItem.leftBarButtonItem =
UIBarButtonItem(image:StyleKit.imageOfMap, style:.Plain, target:self, action:nil);
to a backBarButtonItem
:
self.navigationItem.backBarButtonItem =
UIBarButtonItem(image:StyleKit.imageOfMap, style:.Plain, target:self, action:nil);
in order to take advantage of backBarButtonItem
's default action.
And put that line of code in the view controller preceding the one you'd like your custom back button to appear in.
Edit: If you don't want the "<" symbol to appear on your button, you'll have to in fact use a leftBarButtonItem
then dismiss the view controller in a separate method, ex:
self.navigationItem.leftBarButtonItem =
UIBarButtonItem(image:StyleKit.imageOfMap, style:.Plain, target:self, action:"backButtonPressed:");
}
func backButtonPressed(sender:UIButton) {
navigationController?.popViewControllerAnimated(true)
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…