有人能看出来吗。如何在iPhone中创建下拉菜单,我想在导航栏中添加下拉菜单(我的概念是排序(筛选器),所以我想要三个按钮在菜单名称,标题,描述.....)

发布于 2012-07-12 15:38:49
您可以对iPhone使用UIPopoverController。
这是可用的here。
在弹出窗口中,您可以添加一个UIPickerView,并且有一个下拉列表。基本上,在iPhone上,您可以使用UITableView或UIPickerView来模拟下拉列表。要把它放在一个好的容器里,你可以使用上面提到的弹出窗口。
发布于 2012-07-12 15:40:47
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)];
}];发布于 2012-07-13 14:14:44
//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;
} https://stackoverflow.com/questions/11446912
复制相似问题