任何人都可以告訴。如何在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. 爲導航欄添加下拉菜單
- 2. 如何添加導航下拉菜單?
- 3. 在導航欄中添加下拉菜單
- 4. 如何以編程方式將導航欄添加到presentModalViewController?
- 5. 如何以編程方式在Excel表格中添加下拉菜單?
- 6. 添加圖像會中斷我的導航欄下拉菜單
- 7. 將下拉菜單添加到導航欄中
- 8. 導航欄中的css下拉菜單
- 9. 下拉式導航菜單
- 10. 在現有導航菜單中添加下拉菜單
- 11. 如何在自舉導航欄下拉菜單中添加右上箭頭
- 12. 從現有導航欄下拉菜單
- 13. CSS transition bootstrap導航欄下拉菜單
- 14. 導航欄的下拉菜單
- 15. HTML/CSS導航欄下拉菜單不以列表格式
- 16. 如何在我的導航欄中修復此下拉菜單?
- 17. 如何在HTML/PHP中爲導航欄創建下拉菜單?
- 18. 布爾瑪導航欄在導航欄中打開下拉菜單。如何在導航欄之外打開它?
- 19. 在導航視圖中以編程方式將項目添加到菜單組
- 20. 以編程方式將按鈕添加到導航欄
- 21. 以編程方式添加導航欄iOS
- 22. 以編程方式添加菜單
- 23. 如何以編程方式隱藏導航抽屜菜單項?
- 24. 如何在導航菜單欄的下拉菜單中顯示圖像
- 25. 如何以編程方式將導航欄添加到我的應用程序?
- 26. Firefox Addon SDK:如何添加導航工具欄按鈕和下拉菜單
- 27. 如何爲固定導航欄內的下拉菜單添加滾動條
- 28. 如何添加下拉到這個簡單的導航欄?
- 29. 如何使用下拉菜單(C#Winforms)以編程方式將ToolstripDropDownButton添加到工具欄中
- 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