xcode - 使用dismissViewControllerAnimated :completion:

标签 xcode objective-c-blocks

我使用的一些代码使用了已弃用的方法dismissModalViewControllerAnimated。文档说现在使用 dismissViewControllerAnimated:completion: 。我不确定 completion: 部分。就我而言,完成应该是 nilNULL 还是什么?

原代码如下。

- (void)didFinishWithCamera
{
    [self dismissModalViewControllerAnimated:YES];

    if ([self.capturedImages count] > 0)
    {
        if ([self.capturedImages count] == 1)
        {
            // we took a single shot
            [self.imageView setImage:[self.capturedImages objectAtIndex:0]];
        }
        else
        {
            // we took multiple shots, use the list of images for animation
            self.imageView.animationImages = self.capturedImages;

            if (self.capturedImages.count > 0)
                // we are done with the image list until next time
                [self.capturedImages removeAllObjects];

            self.imageView.animationDuration = 5.0;    // show each captured photo for 5 seconds
            self.imageView.animationRepeatCount = 0;   // animate forever (show all photos)
            [self.imageView startAnimating];
        }
    }
}

最佳答案

如果您不关心完成情况,请提供一个空 block :

[self dismissModalViewControllerAnimated:YES
                              completion:^(void){}];

关于xcode - 使用dismissViewControllerAnimated :completion:,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15028204/

相关文章:

iphone - 如何在 Xcode 中添加两个编译器标志

ios - 如何让一个 block 运行一次,但每次我启动 viewController 时?

objective-c - 如何创建一个返回 block 的 objective-c 方法

objective-c - 无法运行 performSelector : afterDelay from CoreMotion Block

ios - 我需要推送通知来提醒用户某事吗

ios - 使用 parse.com 在后台注销

swift - 如何使用 swift 引用文本字段?

ios - Xcode 5 框架/库搜索路径绝对地址

iphone - 在 block 中使用 ivar 返回到其他对象

ios - 在理解部分块时遇到问题