문제

It is said that when a UIView object is created with programmer's code, then initWithFrame is the method to use for initialization, but when the UIView object is created with a NIB, then initWithCoder is used for initialization.

When a new subclass of UIView is created within Xcode, is there a way to make it so that the proper initWithCoder is created, because right now the usual method that is created is initWithFrame and I wonder if there is some steps in Xcode that I did wrong so it created initWithFrame instead -- could I have made it create initWithCoder instead?

도움이 되었습니까?

해결책

You could tweak your Xcode template file (for UIView subclasses) and put the initWithCoder method in - so that you won't have to rewrite it every single time.

If you want to know how to edit those template files, have a look at my answer here :

How to change entire copyright notice template for Xcode?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top