开发者

Windows in iOS, best way to build a multiple-activities app from Android?

i'm currently developing an app for both Android and iOS, thing is... I started with Android and my app has several Activities with different layouts (Screens with different GUI's, if you are not familiar with android), most of them display very different contents; maps, lists with data from databases, images, text fields with buttons and so on (And most of the time the orientation of the screen changes).

The problem comes with iOS:

  • How do I create more windows from IBActions? (Is this a correct approach?).

  • Once I create a Window, how do I create a new Interface? (Do I need another .xib file?)

  • If once the user finishes with one Windows, does the previous window remains in memory and can be re-opened? (Can I use a navigation tab, even though the first windows was 开发者_如何学Pythonnot a using it?) This is a major problem since iPhones do not have a back button and Android relies a lot on those...

  • Also, if I can't split my program in several windows, wouldn't my app use a lot of memory from destroying and building views?

I'm new to Cocoa development and I have already read a book about Objective C programming (which only teaches syntax and so on), another one about simple iPhone apps (all of them were done in one window, changing the views programmatically) and I'm currently reading another one, but i'm unable to find a simple answer to my problem...

I mean I get Obj-C and how to build iPhone apps (well kind-of) but maybe the problem is that I come from a more straight forward development in Android. Each time I see an iOS project, I see it like a total mess, and the documentation in developer.apple.com doesn't help much either, I'm unable to find what I want.

Hope someone has gone through this already and is willing to point me in the right direction, thank you!


I recommend that you start with the View Controller Programming Guide at the apple developer web site. I think you will find it very helpful.

To answer your questions, you can develop each of your views independently. You depending on your purposes, developing each from a nib file could work. In the app I'm working on now, I have some that I develop programmatically and some that I bring in from NIB files. It's all up to you. The guide I mention above discusses both approaches.

Regarding loading views from button presses, you can do that. Depending on the view controller you use, it can be very easily accomplished. WIth the navigation controller, for example, you just create an instance of the view and push it onto the stack. When you're done with the view, you pop it off and your back to your previous view.

With regards to memory, that is always a concern. You might want to take a look at The Memory Management Programming Guide.

Good luck. I'm just starting out with Android development myself.


Chris already provided a great answer but there are a couple of points I want to add to adress specific questions.

iOS apps normally only have a single UIWindow. Within that window you may present multiple views.

Apps are normally organized into several logical screens worth of content, each managed by some UIViewController subclass.

Each UIViewController instance has a root view which may contain many subviews. A UIViewController's view is expected to fill its window or some frame provided by one of Apple's container view controller classes (UINavigationController, UITabBarController, UISplitViewController, and so on). You should not add one UIViewController's view as a subview of another UIViewController's view.

UIViewControllers will attempt to unload their views when the application receives a memory warning if the view is not visible. See the class' life cycle methods like -viewDidUnload. You should support and take advantage of this behavior to reduce your memory footprint. Keeping UIViewControllers in memory without their views loaded should have a minimal overhead, allows you to keep some persistent state, and each controller's view can be reloaded when needed.

Normally to transition between views a control will send a message to the current view controller (often via an IBAction binding). The current controller will then trigger a transition to another view controller. It might do so by creating a new view controller and pushing it onto the current navigation controller or presenting the new controller as a modal. It might have a reference to some existing controller and present that. It might dismiss itself from a navigation stack to reveal the previous controller. It might even pass the message up the controller's hierarchy until some parent switches the visible tab, dismisses or presents a modal, and so on.

You might also trigger smaller transitions by responding to an IBAction by adding, removing, hiding, or moving subviews of a UIViewController's root view.


Flash Builder 4.5.1 Now enables you to build one application and Compile to multiple Devices

UPDATE: Try XAMARIN, it's part of Visual Studio: https://www.xamarin.com/

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜