From 96bafd2dd16a330fbe69b609e05ddc2a1874318f Mon Sep 17 00:00:00 2001 From: Manuel Binna Date: Fri, 8 Feb 2013 11:11:55 +0100 Subject: [PATCH] Use initWithCoder: instead of awakeFromNib When configuring an SMPageControl from inside a Storyboard or XIB file, the developer might want to use User Defined Runtime Attributes to configure the instance. awakeFromNib is called after those attributes are evaluated by the loading system, effectively overwriting the attributes defined in the Storyboard or XIB file. Therefore, initWithCoder: is the more appropriate location to perform the initialization. --- SMPageControl.m | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/SMPageControl.m b/SMPageControl.m index 020b7e5..e3fe668 100755 --- a/SMPageControl.m +++ b/SMPageControl.m @@ -79,10 +79,15 @@ - (id)initWithFrame:(CGRect)frame return self; } -- (void)awakeFromNib +- (id)initWithCoder:(NSCoder *)aDecoder { - [super awakeFromNib]; - [self _initialize]; + self = [super initWithCoder:aDecoder]; + if (nil == self) { + return nil; + } + + [self _initialize]; + return self; } - (void)dealloc