1

I have a view controller(A) which shows a list of items download from server.

I have another view controller(B) with segmented control.
When second index of segmentedControl is selected, the view controller(B) shows a list of items in the same format as in the controller(A).
When first index of segmentedControl is selected, the view controller(B) shows the items in different format.

I want A and B share a code for the common stuff.

I first thought ok I could move all the view-related code to "common_view class" and use the view class from both controllers.
But, it turns out that there are codes which are not related to view(such as downloading stuff from server, which is controller-part of mvc pattern).

Now I'm perplexed, "is it a good idea to share a controller-part code? is it even possible?"

I could factor out a common code into a commonViewController, and instantiate it from controller(A) and controller(B), and add commonViewController.view as a subview.
But is this really desirable? or do you suggest any better way to do this?

4

1 に答える 1

0

この場合、2 つの NIB を使用します。最初の NIB は、ViewController A と ViewController B の最初のセグメントによって使用されます。ViewController B で 2 番目のセグメントを選択すると、viewControllerA の SubView が追加されます。 、viewcontrollerB の 2 つのセグメント間を切り替えるときに、表示/非表示によって可視性を制御します

于 2012-10-30T14:06:31.140 に答える