fphilipe / PHFComposeBarView

Compose bar from iOS 7 Messages.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Subview layout incorrect if not allocated using initWithFrame:

jverdi opened this issue · comments

Creating a PHFComposeBarView in the following form will result in incorrect sizes for subviews:

PHFComposeBarView *view = [PHFComposeBarView new];
view.frame = CGRectMake(...);

However, this form does work as expected:

PHFComposeBarView *view = [[PHFComposeBarView alloc] initWithFrame:CGRectMake(...)];

-initWithFrame: is the designated initializer of UIView, thus initializing with -init is not expected to work.

I used to think that -init on views would call -initWithFrame:, but at some point my views started to behave in a weird way. Always use the designated initializer, then you won't run into unexpected or rather undefined behavior.