Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/38.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
Ios 以编程方式拍摄屏幕截图时,UISegmentedControl中选定段的标题将消失_Ios_Iphone_Ios7_Uisegmentedcontrol - Fatal编程技术网

Ios 以编程方式拍摄屏幕截图时,UISegmentedControl中选定段的标题将消失

Ios 以编程方式拍摄屏幕截图时,UISegmentedControl中选定段的标题将消失,ios,iphone,ios7,uisegmentedcontrol,Ios,Iphone,Ios7,Uisegmentedcontrol,我将一个UISegmentedControl添加到UIToolbar: UIToolbar *toolbar = [[UIToolbar alloc] initWithFrame:toolbarFrame]; toolbar.barStyle = UIBarStyleBlack; toolbar.translucent = YES; toolbar.barTintColor = [UIColor colorWithRed:0.97 green:0.97 blue:0.97 alpha:1.0];

我将一个
UISegmentedControl
添加到
UIToolbar

UIToolbar *toolbar = [[UIToolbar alloc] initWithFrame:toolbarFrame];
toolbar.barStyle = UIBarStyleBlack;
toolbar.translucent = YES;
toolbar.barTintColor = [UIColor colorWithRed:0.97 green:0.97 blue:0.97 alpha:1.0];
[self.view addSubview:toolbar];

UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:@[@"Last week", @"Last month", @"All time"];
[segmentedControl setSelectedSegmentIndex:0];
[toolbar addSubview:segmentedControl];
然后将工具栏添加到视图控制器中。当我拍摄视图控制器的屏幕截图时,奇怪的事情发生了。选定段的标题将消失

正在使用以下方式拍摄屏幕截图:

UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, YES, [[UIScreen mainScreen] scale]);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
渲染视图:

截图:

从哪里开始查找?

我已替换

[self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; 

现在它的工作原理与预期一致。但我还是不明白为什么会这样

请注意,
drawViewHierarchyInRect:AfterScreen更新:
仅适用于iOS 7。

我已替换

[self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; 

现在它的工作原理与预期一致。但我还是不明白为什么会这样


请注意,
drawViewHierarchyInRect:AfterScreen更新:
仅适用于iOS 7。

有人有想法吗?drawViewHierarchyInRect:AfterCreenUpdates:是的,我们还有一些其他问题…drawViewHierarchyInRect:AfterCreenUpdates:给您造成了什么问题?iOS8上的drawViewHierarchyInRect有时速度较慢,结果显示为白色图像。我试图替换上面回答中提到的线条,但我仍然面临同样的问题。SegmentedControl的文本在截图中消失了。有人有想法吗?drawViewHierarchyInRect:AfterCreenUpdates:是的,我们还有一些其他问题…drawViewHierarchyInRect:AfterCreenUpdates:给您造成了什么问题?iOS8上的drawViewHierarchyInRect有时速度较慢,结果显示为白色图像。我试图替换上面回答中提到的线条,但我仍然面临同样的问题。SegmentedControl的文本在屏幕截图中消失。