What Happened to the Uiview() Constructor in Swift 3.0

Xcode won't let me use NSObject's init() function for UIView

To close this thread/question, I'll add an answer.

I wasn't the one who solved this. This project, if not mentioned in the question, is merely a side project, from a remote/freelance work. I was actually, if not mentioned above too, migrating the project to Swift 4.2. Along the way, this issue came up. I didn't bother to rename all the pieces of codes to be renamed during the update. Long story short, I gave up on this task for a bit, but someone in the company decided to solve it.

The solution is: finish the migration first. Just rename all the stuff that is needed for Swift 4.2, and update the pods as well. That's it! :) I hope this helps people in the future.

Swift 3 : Warning Unused result of call when overriding BecomeFirstResponder

The bug has been solved in the lastest Swift version.

Swift 3 : Warning Unused result of call when overriding BecomeFirstResponder

The bug has been solved in the lastest Swift version.

How do I get and store an initial value of a property of a UIView?

You cannot declare it as a class level property because it won't be created until the ViewController is instantiated. I think what you want to do is as follows.

//instantiate with an initial value of 0.0 
public var inputRest : CGFloat = 0.0

override func viewDidLoad() {
super.viewDidLoad()

//you can do this here, because the userInputView will have been created
self.inputRest = self.userInputView.frame.origin.y
}

This is an inherent limitation of ViewControllers which are instantiated from a storyboard not being able to have let properties which can only be defined once. There are ways around this by overwriting the constructor used to create the view controller from the coder, but it's a lot of work, not easy to read, and very much a lot of work for nothing.



Related Topics



Leave a reply



Submit