问题
in my iOS project i've been re-using the same 3 different types of UI elements:
- Label
- input
- check mark (or X ).
And the logic is the same:
- when the user is entering text, validate.
- while validation fails, red check mark,etc.
So, the next obvious stage is to refactor this into one UIView so that I can just drag and drop.
And I want this into a Cocoa pod.
Refactoring the elements into a UIview, etc is not hard. But I'm stuck on putting this logic into a Cocoa Pod. The XIB doesn't load so the subview is empty.
I've added IB_DESIGNABLE
to the header file but still no rendering. And exception at runtime.
Suggestions? What can I post to help?
EDIT:
My resource section of the podspec
s.source_files = 'Pod/Classes/**/*' s.resources = 'Pod/Assets/**/*' s.resource_bundles = { 'jawbreaker' => ['Pod/Assets/*.png'] }
回答1:
UIView doesnt load XIB file automatically. When you create an UIView class you need something like this: http://eppz.eu/blog/uiview-from-xib-simplest/ .
MyView *view = [Myview loadFromNib];
An if you want use IB_DESIGNABLE remember: https://stackoverflow.com/a/26202160/846780
回答2:
You might be missing the s.resource_bundle
directive, where you specify which NIBs to load.
来源:https://stackoverflow.com/questions/29082170/refactoring-3-different-ui-components-into-one-uiview-into-a-cocoapod