3

when i want to change uibuttons title size i am getting this error.

unfortunately this is working for one button but when i am trying for more then one button its not working.

here is my code which is working for one button

 override func viewDidLoad() {
   btnconfidentiality.setTitle("CONFIDENTIALITY AGREEMENT", forState: .Normal)
    btnconfidentiality.titleLabel?.adjustsFontSizeToFitWidth = true



}

@IBAction func onclickconfidentiality(sender: AnyObject) {
    sender.titleLabel?!.textColor = UIColor.blueColor()
    btnconfidentiality.titleLabel!.font =  UIFont(name: "HelveticaNeue", size: 25.0)
    btncontact.titleLabel!.font =  UIFont(name: "HelveticaNeue", size: 25.0)
}

but when i am trying for another button i am getting error

override func viewDidLoad() {
   btnconfidentiality.setTitle("CONFIDENTIALITY AGREEMENT", forState: .Normal)
    btnconfidentiality.titleLabel?.adjustsFontSizeToFitWidth = true

    btnbyticket.setTitle("BUY A TICKET", forState: .Normal)


}

@IBAction func onclickconfidentiality(sender: AnyObject) {
    sender.titleLabel?!.textColor = UIColor.blueColor()
    btnconfidentiality.titleLabel!.font =  UIFont(name: "HelveticaNeue", size: 25.0)
    btncontact.titleLabel!.font =  UIFont(name: "HelveticaNeue", size: 25.0)
}

@IBAction func onclickbuyaticket(sender: AnyObject) {
    btnbyticket.titleLabel!.font =  UIFont(name: "HelveticaNeue", size: 25.0)
}

enter image description here

Govind Rakholiya
  • 427
  • 6
  • 24
  • Is a custom view calling this controller? – Olla Ashour Dec 07 '15 at 11:36
  • yes its a sliderbar its comes out on click event of menu button.@OllaAhmed – Govind Rakholiya Dec 07 '15 at 11:43
  • A similar issue occurred with me in iOS 9.1 but in objective c. It was because I was assigning views not adding it to the content view of the view controller. If you were to check using the zombie tool in instruments, you most probably will find that the menu button object is no longer in memory and that your IBAction is not called. Try to add it to the content view and see what happens. – Olla Ashour Dec 07 '15 at 12:22
  • i am new in ios so can you plz tell me that how can i assign it to content view..i have a selectviewcontroller and menubutton is in this controller and on the click of this button another viewcontroller display as a slider its a leftviewcontroller and my buttons are on this view controller@OllaAhmed – Govind Rakholiya Dec 07 '15 at 12:51
  • Could you please post the code of the menuButton. – Olla Ashour Dec 07 '15 at 13:04
  • I need to know to know how you are presenting your view controller. Also view this link, it may help you. http://stackoverflow.com/questions/32705171/ibaction-inside-uitableviewcell-not-called-in-ios-9 In my case it was solved as such, but it was in objective c, I was also using a 3rd party and I changed the class to a UIView instead of a view controller. `- (IBAction)openBranchInfo:(id)sender { BranchInfoPopupView *btnView = [[BranchInfoPopupView alloc] initWithFrame:CGRectMake(0, 0, 280, 200)]; [[KGModal sharedInstance] showWithContentView:btnView andAnimated:YES]; }` – Olla Ashour Dec 07 '15 at 13:12
  • actually i am using third party library so on click of menu button its simply call one function @IBAction func btnmenu(sender: AnyObject) { self.slideMenuController()?.openLeft() } – Govind Rakholiya Dec 07 '15 at 13:18
  • I'm not sure really what is the problem. Add an ALL exception breakpoint and try to use the instruments Zombie tool and it will point out the exact line with the issue. Check it out in Apple's Documentation here. [link](https://developer.apple.com/library/ios/recipes/Instruments_help_articles/FindingMessagesSenttoDeallocatedObjects/FindingMessagesSenttoDeallocatedObjects.html) – Olla Ashour Dec 07 '15 at 13:41

1 Answers1

-1

The first instruction inside viewDidLoad should be calling super:

override func viewDidLoad() {
   super.viewDidLoad()
}
Sohil R. Memon
  • 9,404
  • 1
  • 31
  • 57
Edgar
  • 2,500
  • 19
  • 31