logo
down
shadow

how to instantiate an NSLayoutConstraint in swift? (Xcode 6.1.1)


how to instantiate an NSLayoutConstraint in swift? (Xcode 6.1.1)

By : user2953287
Date : November 20 2020, 01:01 AM
wish help you to fix your issue I think the problem is that imageHeight is double, but the constructor expects a CGFloat, so try
code :
let imageHeight: CGFloat = 10.0
NSLayoutConstraint(item: imageView, attribute: .Height, relatedBy: .Equal, toItem: nil, attribute: .Height, multiplier: 1.0, constant: imageHeight)


Share : facebook icon twitter icon
App crash on iOS 5 - Could not instantiate class named NSLayoutConstraint

App crash on iOS 5 - Could not instantiate class named NSLayoutConstraint


By : Alex2601
Date : March 29 2020, 07:55 AM
it should still fix some issue My app is working very fine on iPhone and Simulator with iOS 6, but when i try to run on iPhone/Simulator with iOS 5 the app crashes , make sure you have unselected use autolayout in interfacebuild
Xcode 7 Swift 2 impossible to instantiate UIViewController subclass of generic UITableViewController

Xcode 7 Swift 2 impossible to instantiate UIViewController subclass of generic UITableViewController


By : Mike
Date : March 29 2020, 07:55 AM
this will help Unfortunately, generic Swift classes are not visible to Objective-C code and also are not supported in Interface Builder (in storyboards and xibs). I find these two points closely related.
As a solution I would suggest you to use aggregation: do not make you view controller generic, but extract some logic to another (generic) class and use it inside your view controller.
Swift 3, Xcode 8 Instantiate View Controller is not working

Swift 3, Xcode 8 Instantiate View Controller is not working


By : Gomerson
Date : March 29 2020, 07:55 AM
it fixes the issue Xcode 8 when it compiles says to change instantiate viewcontroller with identifier to simply, instantiate view controller. I did that, why does it give two errors? , Try like this.
code :
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let viewController = storyboard.instantiateViewController(withIdentifier :"secondViewController") as! UIViewController
self.present(viewController, animated: true)    
Swift 4.0 cannot invoke initializer for type 'NSLayoutConstraint' with an argument list of type '(NSLayoutConstraint)'

Swift 4.0 cannot invoke initializer for type 'NSLayoutConstraint' with an argument list of type '(NSLayoutConstraint)'


By : Jiten
Date : March 29 2020, 07:55 AM
may help you . I am using XCode Version 9.0 (9A235), macOS Sierra Version 10.12.6 (16G29), iOS 11.0. , Your first problem is here:
code :
labelConstraints.append(NSLayoutConstraint(widthConstraint))
labelConstraints.append(widthConstraint)
labelConstraints.activate()
NSLayoutConstraint.activate(labelConstraints)
NSInvalidUnarchiveOperationException: Could not instantiate class named NSLayoutConstraint

NSInvalidUnarchiveOperationException: Could not instantiate class named NSLayoutConstraint


By : Peterson Aquino
Date : March 29 2020, 07:55 AM
like below fixes the issue By default, when you create a new iOS project in Xcode 4.5, your storyboard or XIB is set to use Autolayout, which is a new feature in iOS 6.0. The NSLayoutConstraint class is part of the Autolayout system, and it doesn't exist in older versions of iOS.
If you want to deploy your app to an older version of iOS, you need to change your storyboard or XIB to not use Autolayout. It's a checkbox in the File Inspector:
shadow
Privacy Policy - Terms - Contact Us © ourworld-yourmove.org