爲你的男的女的按鈕,我創建你必須做的國家你的自我怎麼一回事,因爲我沒有時間了點。我忙於工作。
@IBOutlet var btn_male: UIButton! // create outlet for radio button
@IBOutlet var btn_female: UIButton!
var gender : NSString = ""
@IBAction func btn_male_female_click(sender: UIButton) {
switch sender.tag {
case 10:
//male select
if (sender.selected == true) {
sender.selected = false;
btn_male.selected = true;
btn_female.selected = false;
gender = "1"
}else{
sender.selected = true;
btn_male.selected = false;
btn_female.selected = true;
gender = "2"
}
break;
case 20:
//female select
if (sender.selected == true) {
sender.selected = false;
btn_female.selected = true;
btn_male.selected = false;
gender = "2"
}else{
sender.selected = true;
btn_female.selected = false;
btn_male.selected = true;
gender = "1"
}
break;
default:
break;
}
}
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(true)
if profileData.Gender .isEmpty {
}else{
if profileData.Gender == "1"{
self.btn_male.selected = true
}else{
self.btn_female.selected = true
}
}
}
var data:[String:String]{
return ["FirstName":firstName.textVal,"LastName":lastName.textVal,"DateOfBirth":dateOfBirth.textVal,"Email":emailId.textVal,"Mobile":mobile.textVal,"Gender":gender as String,"Country":country.textVal,"State":state.textVal,"City":city.textVal]
}
在你的代碼
@IBAction func addUserBtnPressed(sender: AnyObject) {
profileData.FirstName = self.data["FirstName"]!
profileData.LastName = self.data["LastName"]!
profileData.DateOfBirth = self.data["DateOfBirth"]!
profileData.Email = self.data["Email"]!
profileData.Mobile = self.data["Mobile"]!
if btn_male.selected == true {
profileData.Gender = "1"
}else{
profileData.Gender = "2"
}
profileData.Country = self.data["Country"]!
profileData.State = self.data["State"]!
profileData.City = self.data["City"]!
let toViewController = NextVC
toViewController!.transitioningDelegate = self.transitionManager
presentViewController(toViewController!, animated: true, completion: nil)
}
設計
你能告訴我,改變的單選按鈕狀態的代碼? –
我仍然沒有實現。但我只使用該庫。 – mack
@mack你的問題兄弟 是什麼? –