0

我想为 iphone 应用程序创建一个下拉列表,我希望当用户单击它时显示列表,当单击任何按钮时,它会显示该值并隐藏我使用以下代码实现的列表,但这仅适用于一个值而不适用于其他值

  @interface DropDownViewController : UIViewController {

IBOutlet UILabel*ddText;
IBOutlet UILabel*ddMenu;
IBOutlet UIButton*ddMenuShowButton;


  }

 @property (nonatomic, retain) IBOutlet UILabel *ddText;
 @property (nonatomic, retain) IBOutlet UIView *ddMenu;
 @property (nonatomic,retain) IBOutlet UIButton *ddMenuShowButton;
 - (IBAction)ddMenuShow:(UIButton *)sender;
 - (IBAction)ddMenuSelectionMade:(UIButton *)sender;
 @end



 @implementation DropDownViewController
 @synthesize ddMenu, ddText;
 @synthesize ddMenuShowButton;

 - (IBAction)ddMenuShow:(UIButton *)sender
 {
    self.ddMenu.hidden = NO;
    [sender setTitle:@"▲" forState:UIControlStateNormal];


 }

 - (IBAction)ddMenuSelectionMade:(UIButton *)sender
{

 self.ddText.text = sender.titleLabel.text;
[self.ddMenuShowButton setTitle:@"▼" forState:UIControlStateNormal];


self.ddMenu.hidden = YES;

  }

我有三个按钮红色绿色首先是红色它仅适用于红色仅不适用于其他人如何解决这个问题我在本教程之后使用了这个

http://www.edumobile.org/iphone/iphone-programming-tutorials/a-simple-drop-down-list-for-iphone/

4

2 回答 2

0

在您的文本字段附近添加 UIbutton。单击该按钮时,根据您的 textfileld 大小创建 UITableview。(希望您了解创建 Uitableview)然后在“cellForRowIndex”中加载您的列表视图内容。选择表格的行时,您可以获得值从“didselectrowatIndexPath”并将其加载到文本字段中。之后删除 UItableview。

于 2012-07-04T07:32:06.893 回答
-2

如果您在应用程序中使用 iPhone 工具,那就太好了。您应该UIPickerView在下拉列表的位置使用。它看起来不错,并在移动应用程序中提供了更好的界面

于 2012-07-04T06:44:31.783 回答