Original Android to iOS development conversion (i)

Source: Internet
Author: User

A few words

Very early to start iOS development, but there has been no chance, individual no fruit machine, the last company to work on the Mac mini although on my side, Ash has a layer, but has no chance to boot learning, because things, since the last article, after leaving, the new company to be equipped with the Mac Pro, Just meet their own desire to start fruit software development. Self is also starting from 0, learning it but this 3-4 days, but before the OC still have some understanding, so with the Android feel to do, mobile, not all the layout of the missing components, I believe there are people who go from Android to iOS will have this idea, my idea is:

    • First turn over the structure of iOS
    • Layout A view, how to lay out and manipulate objects in the layout
    • Basic Button,listview,gridview and so on all the use of the build
    • View Jump Pass Value
    • SQLite operations
    • Network operation
    • Local file operations
    • Memory management

Here basically can do some simple application, the best way is to quickly join an iOS project team, the next thing is deep, for Android development experience, go to iOS development is not difficult, it may be difficult to understand the OC, I also have to say that OC's grammar is really wonderful for people accustomed to java/c+, just as the heat of PHP suddenly sees Erlang.

Preparation) OC Foundation, starting from object orientation

About OC Grammar http://www.cnblogs.com/lm3515/archive/2010/12/20/1911135.html This friend summed up very well, after reading this basic can begin.

    

A) HelloWorld

Any language is starting from it, do not explain, when I get the fruit machine first thing is why? Open Xcode and quickly create an iOS HelloWorld.

See the above directory structure, I believe that friends who have done cocos seem to be a little familiar with? In fact, its running process is similar to cocos.

The suffix of the files inside iOS:

. h: As with C, the header file

The. M:message abbreviation, which is the OC pair H file to implement

. MM: If one of our files contains C + + code and OC Code, it is named. mm suffix, and the compiler handles OC and c+ code separately.

. Xib: Formerly known as Nib,nib is directly compiled into binary, xib is an XML file, which is the layout file, is the Layout_xxx.xml inside Android. The project consists of a lunachscreen xib file, which is what iOS displays when it's just started, and if your app starts fast, it's a flash, and the boot slow may show longer, equivalent to loading.

II) process

The entry function for iOS is the main.m file, which

A project project structure diagram as shown above, see this structure, we are very concerned about its process, iOS inside its portal is the main.m file, in main inside the declaration of the operation of the proxy class:

#import <UIKit/UIKit.h> #import "AppDelegate.h" int main (int argc, char * argv[]) {    @autoreleasepool {        Return Uiapplicationmain (argc, argv, Nil, Nsstringfromclass ([Appdelegate class]);    }}

Here we see that the proxy class is started by main, and in this proxy class we can set the iOS default boot which tries to try as the first display, as follows: Appdelegate

#import "AppDelegate.h"#import "ViewController.h"@interfaceappdelegate ()@end@implementationappdelegate-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchoptions {_window=[[UIWindow Alloc]initwithframe:[uiscreen mainscreen].bounds]; Viewcontroller*friendcontroller=[[Viewcontroller alloc]init]; Uinavigationcontroller*navigationcontroller=[[Uinavigationcontroller Alloc]initwithrootviewcontroller:friendcontroller]; _window.rootviewcontroller=Navigationcontroller;
[_window makekeyandvisible];
returnYES;}- (void) Applicationwillresignactive: (UIApplication *) Application {}- (void) Applicationdidenterbackground: (UIApplication *) Application {}- (void) Applicationwillenterforeground: (UIApplication *) Application {}- (void) Applicationdidbecomeactive: (UIApplication *) Application {}- (void) Applicationwillterminate: (UIApplication *) Application {}@end

Here we set the default display of the first view as: Viewcontroller, and we set up a thing:

_window.rootviewcontroller=navigationcontroller;

This we can understand as the context of Android, with this we can control the global management view, the beginning I did not set this, so the view page jump is always jump not over, and the official also recommend this way instead of directly in the view to jump.

III) view

Now that we've come to Viewcontroller, it's the activity,activity in Android that inherits from the activity, and iOS inherits the Uiviewcontroller, so you can manipulate the view of the page here, And the view jump is also our Android inside activity jump.

It jumps in the following way:

Loginviewcontroller *ickimageviewcontroller = [[Loginviewcontroller alloc] init];[ Self.navigationcontroller pushviewcontroller:ickimageviewcontroller Animated:true];

Is the push and pop view way, through the root view that we defined earlier.

Four) layout

The layout of iOS is much more comfortable than Android, because there are fewer screens, no more Android, and there are three different layouts in iOS:

    1. Code: Code layout is not to use the Xib file, direct code to create a button and so on, this is possible in iOS, because the iOS project team development, the artist at the time, also give the building of the XY coordinate location, and the code can be reused a higher degree.
    2. Xib:xib is the previous one, and the Android One activity corresponds to a layout XML, an iOS view corresponds to a xib, but it has to be said that the iOS drag-and-drop is more comfortable than the poor in Android, the effect is much better.
    3. Storyboard: This thing is a newborn, unifies the above two ways, it manages the layout of all the view.

Five) End

OK, these two days can use 3 layouts to create some interface, and then throw some components, the operation of the local database, network download point things, I have been doing the server, also Andrid under the XMPP, just under iOS also practiced hand.

As for the in-depth analysis of iOS, it is really not two days a day can learn, can do and understand is different, the latter is best to learn from others.

The writing is somewhat random and miscellaneous.

  

Original Android to iOS development conversion (i)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.