我想知道如何创建一个 popOver 菜单,当用户点击特定行时,它会作为另一个 popOver 菜单的子菜单滑入..?
popOver 包含称为成分的项目列表。当用户点击 popOver 上的特定项目时,另一个 popOver 应该从它与分类列表一起滑出。我知道如何创建弹出框,但我不知道如何创建这样的东西,因为我是 iPhone 和 iPad 的新手。谢谢
我创建并通过以下代码满足了我的要求。但我想创建像 www.opcenterllc.com -> testimonials 这样的弹出窗口
此代码可能看起来效率不高。但我尽可能地尝试了。
-(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 在我的应用程序中启用。