2013-05-01 3 views
-1

iPad 앱 (XCode 4.6, ios 6.2, ARC 및 스토리 보드)이 있습니다. UIView의 위치에 GCRect를 그렸습니다.그려진 사각형에 UIPopover를 연결하는 방법

CGRect rectangle = CGRectMake([appSelected.aPosX floatValue], [appSelected.aPosY floatValue],[appSelected.aPosW floatValue], [appSelected.aPosH floatValue]); 

나는 그림을 그리는 방법이있다.

-(void)showHTMLHelp:(NSString *)htmlString pointTo:(id)target background:(UIColor *)bgColor { 

UIViewController* popoverContent = [[UIViewController alloc] init]; 
UIView* popoverView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 300)]; 
popoverView.backgroundColor = [UIColor colorWithWhite:(CGFloat)1.0 alpha:(CGFloat)1.0]; // frame color? 
popoverContent.view = popoverView; 

//resize the popover view shown in the current view to the view's size 
popoverContent.contentSizeForViewInPopover = CGSizeMake(200, 300); 

// add the UIWebView for RichText 
UIWebView *webView = [[UIWebView alloc] initWithFrame:popoverView.frame]; 
webView.backgroundColor = [UIColor whiteColor]; // change background color here 

// add the webView to the popover 
[webView loadHTMLString:htmlString baseURL:[NSURL URLWithString:nil]]; 
[popoverView addSubview:webView]; 

//create a popover controller 
popoverController = [[UIPopoverController alloc] initWithContentViewController:popoverContent]; 

//present the popover view non-modal with a refrence to the button pressed within the current view 
if([target isKindOfClass: [UITextField class]]) 
    [popoverController presentPopoverFromRect:((UITextField *)target).frame inView:self.view 
        permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; 
else if([target isKindOfClass: [UISegmentedControl class]]) 
    [popoverController presentPopoverFromRect:((UISegmentedControl *)target).frame inView:self.view 
        permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; 
else if([target isKindOfClass: [UIButton class]]) 
    [popoverController presentPopoverFromRect:((UIButton *)target).frame inView:self.view 
        permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; 
else 
    [popoverController presentPopoverFromRect:*(CGRect *)CFBridgingRetain(target) 
             inView:self.view 
        permittedArrowDirections:UIPopoverArrowDirectionAny 
            animated:YES]; 

}

지금 내가 그 사각형에 UIPopover 포인트를 갖고 싶어이는 방법에 대한 코드입니다. GCRect는 C 구조체이기 때문에 어떻게해야 할지를 알 수 없습니다. 이것은 내가 시도한 것이지만, 분명히 잘못된 것입니다. 어떻게해야합니까?

PreferencesViewController *pvc = [[PreferencesViewController alloc] init]; 
[pvc showHTMLHelp:html pointTo: rectangle background:[UIColor whiteColor]]; 
+0

'target '의 유형은 무엇입니까? GCRect가 아니라'CGRect'라고 가정합니다. – Mar0ux

+0

** CGRectMake 생성에 대한 질문 ** – SpokaneDude

답변

1

절대적 오브젝티브 C 방법에 C 구조 (또는 C 프리미티브 변수) 전달에 문제가없는이 나는 방법은 팝 오버를 표시하는 호출 코드이다.

[popoverController presentPopoverFromRect:rectangle 
            inView:self.view 
       permittedArrowDirections:UIPopoverArrowDirectionAny 
           animated:YES]; 

을 그리고 Mar0ux 이미 지적했듯이, 그것은 CGRect있어 :

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

간단히 다음과 같이 호출 : 머리글 (또는 문서)로 말할 수있는 사실, presentPopoverFromRect:inView:permittedArrowDirections:animated: 간단한 CGRect 소요 , 아니 GCRect. CGCore Graphics을 나타냅니다.

+0

이 빌드 오류 받기 : 호환되지 않는 유형 'CGRect'(일명 'struct CGRect')의 매개 변수에 '__strong id'를 전송 함 – SpokaneDude

+0

즉 'target'은 Obj- C 객체가 아니라 CGRect이다. '목표'란 무엇입니까? – DrummerB

+0

명백히'CGRect'를 사용하십시오. 내 게시물을 업데이트했습니다. – DrummerB

0

왜 CGRect를 전송하고 'id'로 전송했는지 묻습니다. 감각은 어디 있니?! 매개 변수 유형을 CGRect로 변경하는 것을 선호합니다.

친절하게 제공합니다.

관련 문제