开发者

Basing a 2nd Interface Builder XIB file on an existing one

开发者 https://www.devze.com 2023-02-27 07:07 出处:网络
I need to create a few Views that are very similar - would it be a good/bad idea just to copy the existing .xib, and then modify the copy? i.e. would that cause circula开发者_JAVA技巧r references or m

I need to create a few Views that are very similar - would it be a good/bad idea just to copy the existing .xib, and then modify the copy? i.e. would that cause circula开发者_JAVA技巧r references or more hassles than it's worth? If it is worth doing, is there a way to do from within XCode, or do you need to do from terminal/file manager? I am looking for a way to quickly generate very similar views without reconstructing from scratch


You can just instantiate multiple UIViewController instances using the same xib, and then make any changes you want to each instance.

UIViewController *firstView = [[UIViewController alloc] initWithNibName:@"MyXIB" bundle:nil];
UIViewController *secondView = [[UIViewController alloc] initWithNibName:@"MyXIB" bundle:nil];

etc...

You can also replace UIViewController with the name of a UIViewController subclass if needed.

0

精彩评论

暂无评论...
验证码 换一张
取 消