I am currently using:
我目前正在使用:
CGRect rect = [self.view bounds];
UIGraphicsBeginImageContextWithOptions(rect.size,YES,0.0f);
CGContextRef context = UIGraphicsGetCurrentContext();
[self.view.layer renderInContext:context];
UIImage *capturedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
This retrieves a screen shot of the current view once a UITabBarItem
is selected. The problem is, this will always capture the view
of the current view
the user is active on before switching to the next view
.
一旦选择了UITabBarItem,这将检索当前视图的屏幕截图。问题是,这将始终捕获用户在切换到下一个视图之前处于活动状态的当前视图的视图。
To better understand this. I have a UITabBarController
that manages my navigation for my app. The walk in View controller
is a table that I want to always capture a picture of when the user selects the Share
UITabBarItem
on the navigation. So I have this linked to a method that checks to see if Share
has been clicked and creates an image of the current view as shown above.
为了更好地理解这一点我有一个UITabBarController来管理我的应用程序的导航。 walk in View控制器是一个表,我希望始终捕获用户在导航上选择Share UITabBarItem时的图片。因此,我将此链接到一个方法,该方法检查是否已单击“共享”并创建当前视图的图像,如上所示。
My roadblock is, how can I capture an image of that first view(walk in view) every time no matter what view the user is currently on?
我的包版是,无论用户当前在哪个视图,我怎样才能每次捕获第一个视图的图像(走进视图)?
I am handling my capturing functionality within a custom class that initates the UITabBarController
我正在一个启动UITabBarController的自定义类中处理我的捕获功能
Suggestions thoughts?
2 个解决方案
#1
Will this help you?
这对你有帮助吗?
CGRect rect = [yourTabController.viewControllers[walkInViewIndex].view bounds];
UIGraphicsBeginImageContextWithOptions(rect.size,YES,0.0f);
CGContextRef context = UIGraphicsGetCurrentContext();
[yourTabController.viewControllers[walkInViewIndex].view.layer renderInContext:context];
UIImage *capturedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
#2
[self.view.layer renderInContext:context];
This explicitly takes a snapshot of the current view (self.view). What you'll want to do is more or less the same procedure, but by specifying your walk in view instead:
这显式地获取当前视图的快照(self.view)。您要做的或多或少是相同的过程,但通过指定您的步入视图:
[self.walkingController.view.layer renderInContext:context];
#1
Will this help you?
这对你有帮助吗?
CGRect rect = [yourTabController.viewControllers[walkInViewIndex].view bounds];
UIGraphicsBeginImageContextWithOptions(rect.size,YES,0.0f);
CGContextRef context = UIGraphicsGetCurrentContext();
[yourTabController.viewControllers[walkInViewIndex].view.layer renderInContext:context];
UIImage *capturedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
#2
[self.view.layer renderInContext:context];
This explicitly takes a snapshot of the current view (self.view). What you'll want to do is more or less the same procedure, but by specifying your walk in view instead:
这显式地获取当前视图的快照(self.view)。您要做的或多或少是相同的过程,但通过指定您的步入视图:
[self.walkingController.view.layer renderInContext:context];