Reputation: 105
I know this is very simple question to ask but anyhow I couldn't find any solution from my own. I have one "repeat_Check", if I press for first time I present one view and if I press same "repeat_Check" for second time I have to hide the view. Its work fine for first time but not working on second time
here my sample code
@IBAction func repeat_button(sender: AnyObject) {
repeat_Check.selected = true
Checked = true
if Checked == true {
self.excludeView.hidden = true
self.view2.hidden = false
self.view2.frame = view2Frame
var buttonFrame = view3Frame
buttonFrame.origin.y = (self.excludeView.frame.origin.y + self.view2Frame.origin.y)
self.view3.frame = buttonFrame
Checked = false
}else if Checked == false {
let buttonviewFrame = self.view2.frame
self.view3.frame = buttonviewFrame
Checked = true
}
Checked = false
}
Upvotes: 0
Views: 197
Reputation: 22374
when you click on button you always make Checked = true
... so condition always true
rather set Checked = true in viewDidload()
and than in button action
@IBAction func repeat_button(sender: AnyObject) {
repeat_Check.selected = true
if Checked == true {
self.excludeView.hidden = true
self.view2.hidden = false
self.view2.frame = view2Frame
var buttonFrame = view3Frame
buttonFrame.origin.y = (self.excludeView.frame.origin.y + self.view2Frame.origin.y)
self.view3.frame = buttonFrame
Checked = false
}else if Checked == false {
let buttonviewFrame = self.view2.frame
self.view3.frame = buttonviewFrame
Checked = true
}
}
Upvotes: 1