3

UIPopoverControlleriPad用のアプリケーションを作成していますが、それが属する行の詳細開示ボタンを指す矢印の付いたを表示したいと思います。メソッドでこれを実行したいと思いますtableView:accessoryButtonTappedForRowWithIndexPath:。現在、私はこれを持っています、ダミーでCGRect

- (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が閉じられるまで何かを選択することを無効にすることも可能ですか(完璧主義)?

4

1 に答える 1

9

あなたが望むことをするには、accessoryView が必要で、accessoryType を設定しても作成されません。ただし、ボタンを作成して cell.accessoryView として設定すると機能します。

セルが作成されたら、accessoryView を作成して設定します。

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

tableView:accessoryButtonTappedForRowWithIndexPath: を discoverDetails: に置き換えます。これは以前のものとよく似ているため、以下に変更点のみを示します。

- (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];
    ...
}

これがどのように見えるかです

ここに画像の説明を入力

于 2011-10-21T14:31:29.013 に答える