2010-07-03 3 views
3

iPad 용 응용 프로그램을 만들고 있는데, UIPopoverController에 속한 행에 대한 세부 공개 버튼을 가리키는 화살표가 표시됩니다. tableView:accessoryButtonTappedForRowWithIndexPath: 메소드에서이 작업을 수행하려고합니다. 현재 내가 더미 CGRect와 함께이 있습니다 또한UITableViewCell의 세부 공개 버튼에서 UIPopoverController 표시

- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath { 
    // Dismiss in the case it shows itself somewhere else 
    [addFeedPopup dismissPopoverAnimated:YES]; 

    // Set up 
    TNSubscribeToFeedController *subscribeToFeedController = [[TNSubscribeToFeedController alloc] initWithNibName:@"SubscribeToFeed" bundle:nil]; 
    UINavigationController *subscribeToFeedNavigationController = [[UINavigationController alloc] initWithRootViewController:subscribeToFeedController]; 
    subscribeToFeedController.title = @"Subscribe to feed"; 
    subscribeToFeedController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:nil]; 
    subscribeToFeedController.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:nil]; 
    /* 
    * Note that we use the UINavigationController pure for the nices UINavigationBar. 
    */ 

    // Show in popup 
    addFeedPopup = [[UIPopoverController alloc] initWithContentViewController:subscribeToFeedNavigationController]; 
    addFeedPopup.popoverContentSize = CGSizeMake(480, 320); 
    [addFeedPopup presentPopoverFromRect:CGRectMake(0, 0, 20, 20) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionLeft animated:YES]; 

    // Memory 
    [subscribeToFeedNavigationController release]; 
    [subscribeToFeedController release]; 
} 

UITableView가 편집 모드에있을 때 내 행을 설정하려면이를 사용하기 때문에, 상세 공개 버튼을 왼쪽으로 약 60 픽셀 :

if (cell == nil) { 
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"SectionTwoCell"] autorelease]; 
} 
cell.textLabel.text = [NSString stringWithFormat:@"Feed %d", indexPath.row]; 
cell.detailTextLabel.text = @"Description"; 
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton; 
cell.editingAccessoryType = cell.accessoryType; 
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^// 
//  TWO LINES BACK DEAR SO USER  // 

누구든지이 문제를 해결할 수 있습니까? 감사.


아, 그리고 스크롤을 해제하고 UIPopoverController이 (완벽)를 닫을 때까지 아무것도 선택하지 않도록하는 것도 가능하다?

답변

9

원하는 것을 수행하려면 accessoryView가 필요하고 accessoryType을 설정해도 accessoryType이 생성되지 않습니다. 그러나 버튼을 만들어 cell.accessoryView로 설정하면 작동합니다.

만들고 셀이 생성 된 accessoryView 설정 :

... 
    UIButton *disclosureButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; 
    [disclosureButton addTarget:self action:@selector(discloseDetails:) forControlEvents:UIControlEventTouchUpInside]; 
    cell.accessoryView = disclosureButton; 
    ... 

가있는 tableView를 교체 : accessoryButtonTappedForRowWithIndexPath : discloseDetails에 :를 당신이 셀 필요가없는 경우에도 간단하게, 그것은 할 수

- (void) discloseDetails:(UIButton *)sender { 
    ... 
    UITableViewCell *cell = (UITableViewCell *) sender.superview; 
    NSIndexPath *indexPath = [self.tableView indexPathForCell:cell]; // if needed 
    [addFeedPopup presentPopoverFromRect:cell.accessoryView.bounds inView:cell.accessoryView permittedArrowDirections:UIPopoverArrowDirectionLeft animated:YES]; 
    ... 
} 

:

여기
- (void) discloseDetails:(UIButton *)sender { 
    ... 
    [addFeedPopup presentPopoverFromRect:sender.bounds inView:sender permittedArrowDirections:UIPopoverArrowDirectionLeft animated:YES]; 
    ... 
} 

무엇을의이 많이 그래서 난 아래의 변화를 넣어 만했습니다 전에 가지고있는 것 같습니다 모양은

enter image description here