Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/43.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 确认反向导航_Iphone_Objective C_Ios7_Xcode5 - Fatal编程技术网

Iphone 确认反向导航

Iphone 确认反向导航,iphone,objective-c,ios7,xcode5,Iphone,Objective C,Ios7,Xcode5,我只想确认一个视图的向后导航。特定视图是UICollectionViewController。我知道我在if语句中的确切编码不正确。我不太清楚怎么做。帮我填空好吗 CollectionViewController.m - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. BOOL isThisViewACollectionView = Y

我只想确认一个视图的向后导航。特定视图是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];
    }
}

逻辑上有问题,, 当您已删除viewcontroller时,将调用以下语句

   if ([self.navigationController.viewControllers indexOfObject:self]==NSNotFound) {

    }
因此,更好的解决方案是在“上面(之前)”的某个位置保存一个值,该值将消失,从而知道viewcontroller是否为uicollectionView(比方说BOOL)
假设此值为真,请提醒用户(填写缺失的代码)。

您能给我举个例子吗?在viewDidLoad中设置一个BOOL值-例如BOOL isThisViewACollectionView=YES;您缺少的代码是if(isThisViewACollectionView){//将出现一个警报}更新的代码。它在viewWillDissapear中表示isThisViewACollectionView是一个未声明的标识符