任何人都可以告诉。如何在iPhone中创建下拉菜单,并且我想在导航条中添加下拉菜单(我的概念是排序(过滤器),所以我想要菜单名称,标题,描述中的三个按钮.....) 如何以编程方式在导航栏中添加下拉菜单?
1
A
回答
1
您可以使用iPhone的UIPopoverController
。
它可用here。
在弹出窗口中,您可以添加一个UIPickerView
,并有下拉菜单。 基本上,在iPhone上,您可以使用UITableView
或UIPickerView
来模拟下拉菜单。 并将它放在一个漂亮的容器中,你可以使用上面提到的popover。
0
iOS
中没有这样的组件,所以您需要自己创建它。 您可以通过在您的按钮下添加一个UIView
并为其设置动画效果。 喜欢的东西...
[self.view addSubview:myMenu];
[myMenu setFrame:CGRectMake(100,30,150,0)];
[UIView animateWithDuration:0.4 animation:^{
[myMenu setFrame:CGRectMake(100,30,150,200)];
}];
0
//on Drop down button click
-(IBAction)btnDropdownPressed:(id)sender{
if (![popoverController isPopoverVisible])
{
PopOverViewController *attShow=[[PopOverViewController alloc]initWithNibName:@"PopOverViewController" bundle:nil];
NSLog(@"arrFiles==%@",arrFiles);
attShow.arrFiles=arrFiles;
{
popoverController=[[[UIPopoverController alloc]initWithContentViewController:attShow] retain];
[popoverController setPopoverContentSize:CGSizeMake(500,250)];
[popoverController presentPopoverFromRect:CGRectMake(0,0, 500, 30) inView:btnMore permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES];
}else {
[popoverController dismissPopoverAnimated:YES];
}
}
PopOverViewController.h
{
IBOutlet UITableView *tblView;
NSArray *arrFiles;
}
@property(nonatomic,retain)NSArray *arrFiles;
PopOverViewController.m
- (NSInteger)tableView:(UITableView *)aTableView numberOfRowsInSection:(NSInteger)section
{
return [self.arrFiles count];
}
-(CGFloat)tableView:(UITableView *)aTableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 40;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
cell.textLabel.text=[self.arrFiles objectAtIndex:indexPath.row];
cell.textLabel.font=[UIFont fontWithName:@"Arial" size:14.0f];
cell.selectionStyle=UITableViewCellSelectionStyleNone;
return cell;
}
相关问题
- 1. 如何以编程方式将导航栏添加到presentModalViewController?
- 2. 将下拉菜单添加到导航栏中
- 3. 添加图像会中断我的导航栏下拉菜单
- 4. 如何以编程方式在Excel表格中添加下拉菜单?
- 5. 下拉式导航菜单
- 6. 从现有导航栏下拉菜单
- 7. CSS transition bootstrap导航栏下拉菜单
- 8. 如何在HTML/PHP中为导航栏创建下拉菜单?
- 9. 布尔玛导航栏在导航栏中打开下拉菜单。如何在导航栏之外打开它?
- 10. 以编程方式将按钮添加到导航栏
- 11. 如何以编程方式隐藏导航抽屉菜单项?
- 12. Firefox Addon SDK:如何添加导航工具栏按钮和下拉菜单
- 13. 如何以编程方式将导航栏添加到我的应用程序?
- 14. 引导程序4导航栏下拉菜单右键
- 15. 以编程方式添加动作栏菜单项目
- 16. 如何以编程方式滚动下拉菜单
- 17. 导航栏导航栏品牌跳转到导航栏菜单下方
- 18. Javascript将菜单添加到导航栏
- 19. 如何添加一个下拉菜单到我的菜单栏
- 20. materializecss导航下拉菜单
- 21. Sprite导航下拉菜单
- 22. 下拉导航菜单
- 23. jQuery下拉导航菜单
- 24. 如何做Bootstrap导航下拉菜单?
- 25. 如何以编程方式打开引导移动导航栏?
- 26. 如何在UISplitViewController的导航栏下方添加搜索栏?
- 27. WordPress的下拉菜单导航菜单
- 28. 如何从导航栏(iOS)创建下拉菜单
- 29. 如何将导航栏自动转换为下拉菜单
- 30. 如何创建带有下拉菜单自定义导航栏
不,你不能很遗憾。 'UIPopoverController'是iPad专用的。请参阅[docs](http://developer.apple.com/library/ios/#documentation/uikit/reference/UIPopoverController_class/Reference/Reference.html) – Krumelur 2012-07-13 06:40:37
是的,“UIPopoverController”仅适用于iPad,但我已将一个链接到一个自定义的'UIPopoverController',这也适用于iPhone。 – George 2012-07-13 07:22:13
我的评论意味着去其他答案。对于那个很抱歉。谢谢你的提示,顺便说一下! – Krumelur 2012-07-13 10:40:30