How to manage a complex subview on the iPhone
I have a view controller that manage a view with a table view, a toolbar, a navigation bar and so on.
Inside the toolbar, I have a GPS signal indicator. It is composed of a number of bars with different heights, different colors, and so on depending on signal quality.
The GPS signal indicator is a complex (sub)view that I want to reuse even in other screens.
How can I manage it? I would like to put it in a view controller, but I'm not sure if it works properly... Moreover, it seems that Apple says t开发者_运维技巧o use one view controller per screen of content... Do you have any ideas?
Thank you very much!
EDIT: In the Apple documentation I read "Note: If you want to divide a single screen into multiple areas and manage each one separately, use generic controller objects (custom objects descending from NSObject) instead of view controller objects to manage each subsection of the screen. Then use a single view controller object to manage the generic controller objects. The view controller coordinates the overall screen interactions but forwards messages as needed to the generic controller objects it manages." -- View Controller Programming Guide for iPhone OS
I'm not sure if this is what I need and I'm not sure how can I implement it... Do you have any ideas or code samples to point me?
I would implement the GPS signal indicator as a subclass of UIView and manage it through instance methods or delegate methods. Then you can re-use that class whenever you need one.
精彩评论