ios - self.view.size in a custom view returns [0,0] -


i have custom view:

@interface mailattributesview : uiview  { ...   @implementation mailattributesview {     uiview *_selectionview; } (id)initwithframe:(cgrect)frame {     self = [super initwithframe:frame];     if (self) {         dlog(@"frame.size.width -[%f]; frame.size.height -[%f] ",frame.size.width, frame.size.height);     }     return self; }  -(void)awakefromnib {     [self initview]; }  -(void)initview {     dlog(@"self.frame.size.width -[%f]; self.frame.size.height -[%f] ",self.frame.size.width, self.frame.size.height);      cgrect sectionsize = cgrectmake(0, 0 , self.frame.size.width, self.frame.size.height);     _selectionview = [[uiview alloc] initwithframe:sectionsize];     [_selectionview setbackgroundcolor:[uicolor clearcolor]];      fromfield = [[jstokenfield alloc] initwithframe:cgrectmake(0, 0, self.frame.size.width, row_height)];     [[fromfield label] settext:@"  from:"];     [fromfield setdelegate:self];     [_selectionview addsubview:fromfield]; 

in storyboard i've created view , set custom view class. problem in view call self.view define width of view - returns 0. can hardcore needed values - expect working standard controls work - mean example auto-sizing if rotate , on.

what's misunderstanding?

if adding custom view in storyboards, not using initwithframe:

instead use initwithcoder:

try this:

- (id)initwithcoder:(nscoder *)adecoder {     if (self = [super initwithcoder:adecoder]) {         dlog(@"self.frame.size.width -[%f]; self.frame.size.height -[%f] ",self.frame.size.width, self.frame.size.height);     }      return  self; } 

Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -