按钮动作修饰里面没有正常工作

时间:2015-08-19 09:42:21

标签: ios cocoa-touch uibutton

viewcontroller.h文件

@interface ViewController : UIViewController<kDropDownListViewDelegate>
 {
 NSArray *arryList;
 NSArray *arryList1;
 DropDownListView * Dropobj;
 }

- (IBAction)DropDownPressed:(id)sender;

- (IBAction)DropDownPressed1:(id)sender;

@property (strong, nonatomic) IBOutlet UILabel *lblSelectedCountryNames;


@property (strong, nonatomic) IBOutlet UILabel *lblSelectedCountryNames1;
@end

viewcontroller.m文件

- (void)viewDidLoad 
{

[super viewDidLoad];


arryList=@[@"India",@"Swaziland",@"Africa",@"Australlia",@"Pakistan"];


arryList1=@[@"India1",@"Swaziland1",@"Africa1",@"Australlia1",@"Pakistan"];    

}
 - (void)DropDownListView:(DropDownListView *)dropdownListView didSelectedIndex:(NSInteger)anIndex
{
/*----------------Get Selected Value[Single selection]-----------------*/
    _lblSelectedCountryNames.text=[arryList objectAtIndex:anIndex];
    _lblSelectedCountryNames1.text=[arryList1 objectAtIndex:anIndex];

}
 - (IBAction)DropDownPressed:(id)sender 
{
[Dropobj fadeOut];
[self showPopUpWithTitle:@"Select Country" withOption:arryList xy:CGPointMake(16, 58)     size:CGSizeMake(287, 330) isMultiple:NO];
}
- (IBAction)DropDownPressed1:(id)sender 
{
[Dropobj fadeOut];
[self showPopUpWithTitle:@"Select " withOption:arryList1 xy:CGPointMake(16, 58)     size:CGSizeMake(287, 330) isMultiple:NO];
}

点击DropDownPressed1它没有加载arrylist1 ....而不是加载arrylist ...如果我选择valaue示例india ....那就是值两个标签中都显示了......如何纠正这些问题...如果不清楚请给我发邮件..我会提前发送我的样品项目......

1 个答案:

答案 0 :(得分:0)

更多按钮和标签:

    @interface ViewController : UIViewController<kDropDownListViewDelegate>
     {
     NSArray *arryList;
     NSArray *arryList1;
     DropDownListView * Dropobj;

     int iTappedBtn;
     }


    - (void)DropDownListView:(DropDownListView *)dropdownListView didSelectedIndex:(NSInteger)anIndex
    {
    /*----------------Get Selected Value[Single selection]-----------------*/
         switch (iTappedBtn){
           case 0:
           {
            _lblSelectedCountryNames.text=[arryList objectAtIndex:anIndex];
           } 
           case 1: 
           {
            _lblSelectedCountryNames1.text=[arryList1 objectAtIndex:anIndex];
           }
           // and so on: 
           // case ...
         }
    }
     - (IBAction)DropDownPressed:(id)sender 
    {
    iTappedBtn = 0;

    [Dropobj fadeOut];
    [self showPopUpWithTitle:@"Select Country" withOption:arryList xy:CGPointMake(16, 58)     size:CGSizeMake(287, 330) isMultiple:NO];
    }
    - (IBAction)DropDownPressed1:(id)sender 
    {
    iTappedBtn = 1;

    [Dropobj fadeOut];
    [self showPopUpWithTitle:@"Select " withOption:arryList1 xy:CGPointMake(16, 58)     size:CGSizeMake(287, 330) isMultiple:NO];
    }
    // and so on for other DropDownPressed

这不是很好。但很容易理解。