Best radio-button implementation for IOS

后端 未结 8 586
心在旅途
心在旅途 2020-11-29 20:50

I would like to ask if there are examples out there on how to implement radio-button options on an iPhone app.

I find the Picker View quite big for a simple selectio

8条回答
  •  心在旅途
    2020-11-29 21:45

    I know its very late to answer this but hope this may help anyone.

    you can create button like radio button using IBOutletCollection. create one IBOutletCollection property in our .h file.

    @property (nonatomic, strong) IBOutletCollection(UIButton) NSArray *ButtonArray;
    

    connect all button with this IBOutletCollection and make one IBAction method for all three button.

    - (IBAction)btnTapped:(id)sender {
           for ( int i=0; i < [self.ButtonArray count]; i++) {
               [[self.ButtonArray objectAtIndex:i] setImage:[UIImage                         
                imageNamed:@"radio-off.png"]                 
                forState:UIControlStateNormal];
           }
         [sender setImage:[UIImage imageNamed:@"radio-on.png"]
          forState:UIControlStateNormal];
    }
    

提交回复
热议问题