2012-07-04 26 views
0

我想爲iPhone應用程序做一個下拉列表我希望當用戶點擊它顯示列表,當點擊任何按鈕時,它顯示我已經實現使用的值和隱藏列表在follwoing代碼,但這項工作只爲一個值不是爲別人如何使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; 

    } 

我有三個按鈕,紅色grenn藍色第一個是紅色的它僅適用於僅紅色不是爲別人如何解決這個我已經使用這個下面這個教程

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

+0

您可能想要發佈一些更多的問題代碼或屏幕截圖,因爲它很難理解問題。 –

+0

問題在於,當我按下紅色按鈕時給出了tutoril,但它對其他按鈕無效 – user1495149

+0

但是,您尚未實現本教程中提供的所有內容,或者您​​粘貼的代碼不完整。 –

回答

0

在您的textfield.While附近添加UIbutton根據您的textfileld大小創建UITableview(希望你知道如何創建Uitableview),然後加載你的listview內容在「cellForRowIndex」 。當選擇表格的行時,您可以從「didselectrowatIndexPath」中獲取值並將其加載到文本字段中。然後刪除UItableview。

-2

如果您在您的應用程序中使用iPhone工具,這將是一件好事。您應該在下拉列表中使用UIPickerView。它看起來不錯,並提供更好的移動應用界面

+0

它的好我知道但根據要求我需要使用下拉列表 – user1495149

+0

可憐的人誰想要他們的移動應用程序的網站。如果您要求提供移動應用程序,那麼您應該使用其工具而不是網站工具。 –

+0

你不能說可憐的人,否則他們會想要,因爲他們會覺得用戶友好 – user1495149

相關問題