2011-03-23 4 views
5

UIPopoverArrowDirection을 왼쪽으로 이동하여 실제 화살표가 더 이상 중앙에 있지 않지만 왼쪽에서 25 %, 오른쪽에서 75 % 이상 움직 이길 원합니다.UIPopoverController UIPopoverArrowDirection의 위치 변경

나는이 두 번째처럼되고 싶어 두 개의 스크린 샷을보고 무슨 뜻인지 이해하는 데 도움이

...

Normal Popover

The Popover with correctly placed arrow that I want

문제는 실제적인 방법이 없다는 것입니다 popover 클래스로 파고들 수 있습니다. 누군가 제 3 파티를 만들 수 없다면 사용할 수 있습니까? 사람이 사소한 문제로 보이는이 문제를 해결하는 방법을 알고 있다면

어쨌든 ... 당신이하는 구형을 줄 수있는이에 데이브에게 ~

... 알려 방법 아래

답변

7

"presentPopoverFromRect"를 지정하고 해당 rect를 충분히 제한함으로써 내장 클래스에서 이미 수행 할 수 있습니다.

example doing this

아래의 코드는 바로 위의 결과 코드 꺼낸다. 작은 cogwheel 것은 UINavigationBar의 UIToolbar에 있기 때문에 여분의 보풀이 있습니다. r은 UIToolbar의 프레임이며 올바른 지점 (화살표의 경우)을 맞추기 위해 조정 중이거나 약간 중심을 벗어납니다. MGSettingsView은보기 컨트롤러입니다 ("전환 사용", "야간 모드 사용"등).

UINavigationItem *item = scrollView.navbar.topItem; 
UIToolbar *authorTools = (UIToolbar *)[item.rightBarButtonItem customView]; 
CGRect r = authorTools.frame; 
r.size.width = 18; 
r.origin.x += 12; 

CGSize popoverSize = CGSizeMake(300.f, 500.f); 
MGSettingsView *settingsView = [[MGSettingsView alloc] initWithSize:popoverSize]; 
UIPopoverController *poctl = [[UIPopoverController alloc] initWithContentViewController:settingsView]; 
settingsView.popover = poctl; 
poctl.delegate = self; 
poctl.popoverContentSize = popoverSize; 
[poctl presentPopoverFromRect:r inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; 
[settingsView release]; 

이 질문에 답하지 않은 경우 질문을 잘 표현할 수 있습니다. :)

0

확인을 주시기 바랍니다 arrowDirections 방향입니다.

- (void)presentPopoverFromRect:(CGRect)rect inView:(UIView *)view permittedArrowDirections:(UIPopoverArrowDirection)arrowDirections animated:(BOOL)animated 
+0

@David van Dugteren : 아직 어떤 문제에 직면하고 있는지 알려주세요. – Jhaliya

1

UIPopoverController 클래스 좌표 (사각형)의 콘텐츠를 표시 할 수있는 간단한 방법을 제공한다. 자동화할 popoverArrowDirection을 설정할 수 있습니다. 그게 전부입니다. 이 정보들로부터 시스템은 자동으로 화면에 맞게 popover를 표시하고 원하는 directin을 존중합니다. 더 이상 묻지 않습니다.