UIImagePickerController:捕获后是否可以仅在编辑模式下设置叠加视图?

时间:2011-08-29 07:00:01

标签: ios

我将AllowEditing设置为true,并且在捕获图像后,我想在编辑屏幕中提供其他说明以裁剪出部分图像。这可能吗?

2 个答案:

答案 0 :(得分:3)

UIImagePickerViewController实际上是UINavigationController。这使您能够跟踪UINavigationViewController中的哪个步骤,因此只有在到达第二个视图控制器时才能设置覆盖视图。

简而言之: - UIImagePickerController.delegate = self - 使自己符合UINavigationControllerDelegate协议 - 实施下一个方法:

- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    if ([navigationController.viewControllers indexOfObject:viewController] == 1)
    {
        // If second UIViewController, set your overlay.
    }
}

答案 1 :(得分:0)

Dires De Smet,你的解决方案很好,但还不够好,因为你真的不知道你当前的视图控制器的索引是什么(你可以找到它的诅咒,但它的丑陋)

所以我带来了新的if条件,请查看:
假设self是你当前的UIViewController,而不是一些NSObject子类,
如果self是NSObject子类,那么使用:

UIViewController *currentViewController=(UIViewController *)[[[[[[[UIApplication sharedApplication]delegate]window]rootViewController]navigationController]viewControllers]lastObject];


- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    if (![viewController isKindOfClass:[self class]]){
        //do your thing...
    }
}