私が持っているビューの 1 つの戻るナビゲーションを確認したいだけです。特定のビューは UICollectionViewController です。if ステートメントの正確なコーディングが正しくないことはわかっています。私はそれを行う方法がよくわかりません。私のために空白を埋めますか?
CollectionViewController.m
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
BOOL isThisViewACollectionView = YES;
}
-(void) viewWillDisappear:(BOOL)animated {
if ([self.navigationController.viewControllers indexOfObject:self]==NSNotFound) {
// back button was pressed. We know this is true because self is no longer
// in the navigation stack.
if (isThisViewACollectionView) {
UIAlertView *cameraAlertView = [[UIAlertView alloc] initWithTitle:@"Camera Not Available" message:@"The camera feature isn't available on your device." delegate:nil cancelButtonTitle:@"Okay" otherButtonTitles:nil];
[cameraAlertView show];
}
}else{
[super viewWillDisappear:animated];
}
}