2014-01-27 3 views
1

I UIToolbar는 (A)에 추가 된 UISegmentedControl가 사라진다 :제목, 프로그램

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]; 

툴바이어서 뷰 컨트롤러에 추가된다. View Controller의 스크린 샷을 찍을 때 이상한 일이 발생합니다. 선택한 세그먼트의 제목이 사라집니다.

스크린 샷을 사용하여 촬영하고 있습니다 :

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

렌더링보기 : enter image description here

스크린 샷 : enter image description here

을 이해할 수있을 것이다 찾고 시작하는 위치에 대한 모든 포인터가.

답변

3

나는

[self.view drawViewHierarchyInRect:self.view.bounds afterScreenUpdates:YES]; 

으로

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

를 교체했습니다 그리고 지금은 예상대로 작동합니다. 왜 그런 일이 일어나는지 아직 이해가 안됩니다.

drawViewHierarchyInRect:afterScreenUpdates:은 iOS 7 전용입니다.

+0

하나의 아이디어가 있습니까? drawViewHierarchyInRect : afterScreenUpdates : YES가 우리에게 다른 문제가 있습니다 ... – x2on

+0

'drawViewHierarchyInRect : afterScreenUpdates :'의 원인은 무엇입니까? –

+0

가끔 느린 경우 – x2on

관련 문제