2016-06-02 2 views
-1

내 시나리오는 이와 같습니다. 는 I 소스가 각 셀의 극우 appearning되는 버튼이며, 상기 메뉴 팝 오버 용 enter image description hereios 응용 프로그램의 popover에서 popOver 가져 오기

아래와 같이 다른 창에서 것이다 button.If 화재 그 메뉴를 가지고있는 TableView 셀있다.

diplayAccounts라는 다른 테이블보기가 있습니다. 팝업 메뉴의 셀 (뷰 계층 구조)을 클릭하면 displayAccounts 보기 컨트롤러가 팝업으로 표시되어야합니다. 의심의 여지가 무엇을위한 소스가되어야합니다.

override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { 
menuTapped(self) 
} 

func menuButtonTapped(sender: AnyObject) 
{ 
    let storyboard : UIStoryboard = UIStoryboard(name: "Storyboard", bundle: nil) 
    let vc = storyboard.instantiateViewControllerWithIdentifier("HierarchyTableViewController") as! HierarchyTableViewController 
    vc.modalPresentationStyle = UIModalPresentationStyle.Popover 
    let popover: UIPopoverPresentationController = vc.popoverPresentationController! 
    popover.sourceView = sender as? UIView 
    popover.delegate = self 
    presentViewController(vc, animated: true, completion:nil) 
} 

을 다음과 같이 menuTapped 인 방법 그리고 내가

enter image description here 이 제발 도와주세요지고있어 오류.

+0

는 "지금은 viewHierarchy의 클릭에 또 다른 팝 오버를 취득 할 대리인에게 확인해야합니다 "이게 무슨 뜻이야? – Alexi

+0

diplayAccounts라는 테이블보기가 있습니다. 팝업 메뉴의 셀 (뷰 계층 구조)을 클릭하면 displayAccounts View 컨트롤러가 팝업으로 표시되어야합니다. 의심의 여지가 무엇을위한 소스가되어야합니다. –

답변

0

그것 (애플 모바일 휴먼 인터페이스 가이드 라인에서) 다른 팝 오버 내부에 팝업을 통해 제시하지 않는 것이 좋습니다

당신이 할 수있는 가장 좋은 뷰 컨트롤러 클래스를 통해 팝업에서

처럼

  • 첨부 파일에 표시된대로 항목 목록을 표시하는보기 컨트롤러 클래스에서 대리자 프로토콜을 구현합니다.
  • 해당 델리게이트 프로토콜 내부에서 params가있는 콜백 메소드를 추가하여 선택한 셀의 세부 정보를 포함합니다.
  • popover 클래스의보기 컨트롤러에 대리인 속성을 추가합니다.
  • 셀 선택 이벤트에서 대리자 메서드를 호출합니다.
  • 팝 오버가

    제시되는 버튼을 표시 셀 클래스

팝업 제시 전에 Delegate 객체 초기화를

  • (즉, 상기 셀은 상기 사진에서 44,087 (111)를 표시) 이상
  • 위임 프로토콜에서 선언 된 위임 메서드를 구현하여 선택 이벤트를 가져옵니다.
  • 원하는 다른 팝을 표시합니다.

    UPDATE는

이것은 당신이

PopOverWithListItemsViewController 위의 그림과 같이 항목의 목록이 표시 팝 오버 뷰 컨트롤러 될 것입니다.테이블 뷰 선택 이벤트에서 시간 파일

#import <UIKit/UIKit.h> 

@protocol PopoverWithListItemsViewDelegate <NSObject> 

- (void)didSelectedListItemAtIndex:(NSInteger)index; 

@end 

@interface PopOverWithListItemsViewController : UIViewController 

@property (nonatomic, weak) id<PopoverWithListItemsViewDelegate> delegate; 

@end 

NSInteger indexOfSelectedItem = 4;// jus for demo setting index as 4 
[self.delegate didSelectedListItemAtIndex:indexOfSelectedItem]; 

처럼 그리고 당신은 목록 팝 오버을 제시하고있는 클래스에 위임 호출을 추가, 다음

1 단계를 추가

po를 표시하는 클래스 2 단계

// Let this be the cell's button tap event from which you presenting the pop over 
- (IBAction)buttonTapEvent:(id)sender 
{ 
    // Presenting pop over sections 
    PopOverWithListItemsViewController *listItemsPopOverVC = [[PopOverWithListItemsViewController alloc] init]; 
    listItemsPopOverVC.delegate = self; 
    // pop over presenting with listItemsPopOverVC as popover's view controller 
} 

3 단계를

@interface ViewController() <PopoverWithListItemsViewDelegate> // let ViewController is the class from which you presenting the pop over

다음과 같은 p 이상

// Delegate method implementation. 
- (void)didSelectedListItemAtIndex:(NSInteger)index 
{ 
    // Here we get the index of the selected cell in the popover. 
    // Present the new popover from here, after customizing the new pop over contents. 
} 
+0

몇 가지 코드를 데모로 제공해 주실 수 있습니까? @Alex –

+0

업데이트를 참조하십시오. – Alexi

+0

세 번째 단계에서, 다음 popover에 대한 코드를 작성하라고 알려주지 만 여기에서 찾을 수있는 어려움은 어떻게 단추를 소스로 사용할 수 있는가입니다. 나는 그 참조를 바로 가지고 있지 않다. @Alex –

관련 문제