I've got an app I'm working on and I have quite a bit of data entry during user registration. On the ipad version of the app this is very simple because all the data entry fields can go on a single screen. However on the iphone version this doesn't look as clean and I was wanting to break this across 2 screens. This would require possibly switching between XIBs. So my question is can I use a single view controller and treat 2 XIBs as a single view? This way I can share a single view controller for the ipad & iphone versions of this screen and have all the business logic in a single view controller.

有帮助吗?

解决方案

Yes, you can, assuming of course your XIBs are compatible with your controllers (e.g. your XIBs don't rely on properties that you controller doesn't implement). I have done this successfully without the two-page split requirement, but did not have just one controller class: I also subclassed this controller (one subclass for iPhone and one for iPad) in order to keep the small amount of device-specific logic in its own class.

For the page split I imagine that if you have a separate model object then you can have two controller instances, once for each page's XIB, and get them to work on the same data as you require.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top