Radio button in iPhone app

后端 未结 11 1734
臣服心动
臣服心动 2020-12-06 06:11

I have to add radio buttons in my iPhone application. For that I have got radio button image which is of round in shape. Can I add that image as a subview? and Can I add tou

相关标签:
11条回答
  • 2020-12-06 06:35

    I just published an iOS Radio Button control to Cocoapods pod "DLRadioButton", for documentation and examples, please go to GitHub. Attached are screenshots for this control.enter image description here

    0 讨论(0)
  • 2020-12-06 06:36

    //define property of button

    Declare Unchaked Image

       - (void)viewDidLoad
       {
           [ButtonChaked setBackgroundImage:[UIImage imageNamed:@"UnChacked.png"] forState:UIControlStateNormal];
        }
    

    Chaked Image.

     - (IBAction)ButtonChaked:(id)sender
     {
        if (ButtonChaked.selected ==YES)
        {
          [ButtonChaked setBackgroundImage:[UIImage imageNamed:@"UnChacked.png"] forState:UIControlStateSelected];
    
        ButtonChaked.selected =NO;
    
     }
     else
     {
        [ButtonChaked setBackgroundImage:[UIImage imageNamed:@"Chaked.png"] forState:UIControlStateNormal];
        ButtonChaked.selected = YES;
    
     }
    
    
    }
    

    that's really used

    0 讨论(0)
  • 2020-12-06 06:37

    There is no any RadioButton control in iPhone application.

    Though you can check folliwing link for taking RadioButton.

    Here we placed Two Images in place of RadioButtons.

    http://www.developers-life.com/radio-buttons-in-iphone-application.html

    Enjoy Coding........

    0 讨论(0)
  • 2020-12-06 06:38
    IBOutlet UIButton *checkboxButtonMale; 
    
    IBOutlet UIButton    *checkboxButtonFmale;
    
      checkboxButtonFmale.tag = 3;
      checkboxButtonMale.tag = 2; 
    
    (IBAction)checkboxGenderChecked:(id)sender{ 
    
    
        UIButton *selectedButton = (UIButton *)sender;
        UIButton    *toggledButton; 
    
        if (selectedButton.tag == 2 ) { 
            toggledButton =    checkboxButtonFmale;
        } 
        else {      
            toggledButton = checkboxButtonMale; 
        }   [toggledButton    setSelected:NO]; 
        [sender setSelected:YES];
           }
    
    0 讨论(0)
  • 2020-12-06 06:38

    If you have only "yes" or "no" options then use UISwitch.

    For multiple type use the code below:

    -(void)buttonPressed:(id)sender{
    
    if([sender isSelectd])
    
    //here change button image and set
    
    [sender setSelected:NO];
    
    }else{
    //here change button image and set
    
    [sender setSelected:YES];
    
    }
    

    remember, when you create the button don't forget to set the setSelected to NO.

    0 讨论(0)
提交回复
热议问题