Reputation: 101
let bubbleView : UIView = {
let view = UIView()
view.backgroundColor = blueColor
view.translatesAutoresizingMaskIntoConstraints = false
view.layer.cornerRadius = 16
view.layer.masksToBounds = true
return view
}()
let messageImageView : UIImageView = {
let imageView = UIImageView()
imageView.translatesAutoresizingMaskIntoConstraints = false
imageView.layer.cornerRadius = 16
imageView.layer.masksToBounds = true
imageView.contentMode = .scaleAspectFill
return imageView
}()
init(frame: CGRect) {
super.init(frame: frame)
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
// getting error in like "super.init(frame: frame)" as Must call a designated initializer of the superclass 'UITableViewCell'please help me in sorting this problem thanks in advance...
Upvotes: 9
Views: 12224
Reputation: 31016
From the docs for init(style: UITableViewCellStyle, reuseIdentifier: String?)
:
This method is the designated initializer for the class.
The super
initializer you're calling is for UIView
, not UITableViewCell
.
Upvotes: 5
Reputation: 6859
I guess the code that you provided is from UITableViewCell
type class. So in the initializer you should call designed initializer for this class. Not from UIView
The designated initializer for UITableViewCell
class is
init(style: UITableViewCellStyle, reuseIdentifier: String?)
So in you class you should override this initializers:
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
}
Upvotes: 22