I am using swift. Have some customised UIControls
and UIViews
. They have been dragged into storyboard made IBOutlet
with weak
property.
I ran the App in Allocations Instrument and presents the viewcontroller using all these views and controls. Dismisses the controller but the objects that have been allocated are persistent in memory. On each attempt of presenting the controller, the memory grows accordingly and none of them seems to be released.
I am adding a related control here
import UIKit
@IBDesignable class CNButtonBackground: UIView {
private func initialize()
{
//color is set through context fill in drawRect
self.backgroundColor = UIColor.lightTextColor()
}
override init(frame: CGRect) {
super.init(frame: frame)
//initializing custom components
self.initialize()
}
required init(coder: NSCoder) {
super.init(coder: coder)
//initializing custom components
self.initialize()
}
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
override func drawRect(rect: CGRect)
{
super.drawRect(rect)
// Drawing code
self.layer.cornerRadius = 5.0
self.clipsToBounds = Yes
// Fill color
let context = UIGraphicsGetCurrentContext()
var drawRect: CGRect = CGRectMake(rect.origin.x, rect.origin.y,rect.size.width, rect.size.height);
CGContextSetRGBFillColor(context, 35.0/255.0, 24.0/255.0, 21.0/255.0, 0.8);
CGContextFillRect(context, drawRect);
}
}
What is that I am missing which is causing this issue? Please help me out... Anything I could try out is also fine. Give me directions, I am willing to try all.