You can access the UINavigation stack to see which view is before the previous one assuming you push the new view.
Class aClass = [[[self.navigationController viewControllers] objectAtIndex:self.navigationController.viewControllers.count - 2] class];
if (aClass == [UIViewControllerA class])
//Do something
else if (aClass == [UIVIewControllerB class])
//Do something else
Or create a custom init method for the single view you push to that allows you to pass in a variable as to which view it came from (sorry, really wordy).
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil isFromViewA:(bool)isFromViewA