-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];
}
}
你能否給我提供一個例子? – MacBoss123541
在您的viewDidLoad中設置一個BOOL值 - 例如BOOL isThisViewACollectionView = YES; 並且您的遺漏代碼是if(isThisViewACollectionView){ //將出現警報 } – chewy
已更新的代碼。它在viewWillDissapear中說thisViewACollectionView是一個未聲明的標識符 – MacBoss123541