0

ユーザーが特定の行をタップすると、別の popOver メニューのサブメニューとしてスライドする popOver メニューを作成する方法を知りたい..?

popOver には、構成要素と呼ばれるアイテムのリストが含まれています。ユーザーが popOver の特定のアイテムをタップすると、別の popOver が分類されたリストと共にそこからスライドする必要があります。ポップオーバーの作成方法は知っていますが、iPhone と iPad を初めて使用するため、そのようなものを作成する手がかりがありません。ありがとう

私が作成し、私の要件は次のコードによって満たされます。しかし、www.opcenterllc.com -> 証言のようなポップオーバーを作成したいと思います

このコードは一見効率的ではないかもしれません。しかし、私はできる限りのことを試みました。

-(void)popOverMenu {

    ingrediant=[[NSArray alloc]initWithObjects:@"ingrediant1",@"ingrediant2",@"ingrediant3",@"ingrediant4",@"ingrediant5", nil];

    firstViewController=[[UIViewController alloc]init];
    firstViewController.contentSizeForViewInPopover=CGSizeMake(300, 400);
    navigationController=[[UINavigationController alloc]initWithRootViewController:firstViewController];
    popOverController=[[UIPopoverController alloc]initWithContentViewController:navigationController];

    tblView=[[UITableView alloc]initWithFrame:CGRectMake(20.0, 10.0, 260, 360) style:UITableViewStylePlain];
    tblView.dataSource=self;
    tblView.delegate=self;
    tblView.autoresizesSubviews=YES;

    UILabel *label1=[[UILabel alloc]initWithFrame:CGRectMake(3, 3, 120, 40)];
    label1.text=@"Ingredients";
    label1.textColor=[UIColor whiteColor];
    label1.backgroundColor=[UIColor clearColor];
    label1.textAlignment=UITextAlignmentCenter;

    UIBarButtonItem *rightbar=[[UIBarButtonItem alloc]initWithCustomView:label1];

    UIBarButtonItem *backBarButton=[[UIBarButtonItem alloc]initWithTitle:@"close" style:UIBarButtonItemStylePlain target:self action:@selector(close:)];

    firstViewController.navigationItem.leftBarButtonItem=rightbar;
    firstViewController.navigationItem.rightBarButtonItem=backBarButton;

    [firstViewController.view addSubview:tblView];

    [popOverController presentPopoverFromRect:Button.frame inView:scrollView permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

}

そして

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *tblView2=[tableView cellForRowAtIndexPath:indexPath];

   secondViewController.contentSizeForViewInPopover=CGSizeMake(300, 400);  
   [[secondViewController navigationItem]setTitle:@"Classified"];
    UIBarButtonItem *closeButton=[[UIBarButtonItem alloc]initWithTitle:@"close" style:UIBarButtonItemStyleBordered target:self action:nil];
    secondViewController.navigationItem.rightBarButtonItem=closeButton;

    [secondViewController.view addSubview:tblView2]; 
    [firstViewController.navigationController pushViewController:secondViewController animated:YES];
    [tblView2 reloadData];

}

アプリで ARC が有効になっています。

4

1 に答える 1

0

UINavigationControllerポップオーバー内でa を使用したいようです。これにより、新しいアイテムを「プッシュ」できるようになり、標準の右から左へのスライドイン動作が可能になります。

于 2012-06-11T12:34:50.537 に答える