http://www.sufeinet.com/plugin.php?id=keke_group

苏飞论坛

 找回密码
 马上注册

QQ登录

只需一步,快速开始

分布式系统框架(V2.0) 轻松承载百亿数据,千万流量!讨论专区 - 源码下载 - 官方教程

HttpHelper爬虫框架(V2.7-含.netcore) HttpHelper官方出品,爬虫框架讨论区 - 源码下载 - 在线测试和代码生成

HttpHelper爬虫类(V2.0) 开源的爬虫类,支持多种模式和属性 源码 - 代码生成器 - 讨论区 - 教程- 例子

查看: 2235|回复: 3

[新手开发之旅] iOS新手开发之旅-深入了解第一个应用程序代码

[复制链接]
发表于 2018-11-28 17:52:46 | 显示全部楼层 |阅读模式
本帖最后由 竹林风 于 2018-12-6 14:20 编辑

         文章导航  

        【iOS新手开发之旅】   http://www.sufeinet.com/thread-24000-1-1.html



        创建一个简单的应用程序后会自动生成下面不同的5个文件

       CEDF1599A2964873B91DDF32B4FD417B.png

       AppDelegate.h
     
[Objective-C] 纯文本查看 复制代码
#import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;


@end


    代码说明

  • AppDelegate调用UIResponder来处理iOS事件。
  • 完成UIApplication的命令,提供关键应用程序事件,如启动完毕,终止,等等。
  • 在设备的屏幕上用UIWindow对象来管理和协调各种视角,它就像其它加载视图的基本视图一样。通常一个应用程序只有一个窗口。

         AppDelegate.m      
[Objective-C] 纯文本查看 复制代码
#import "AppDelegate.h"

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    
    
    return YES;
}


- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}


- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}


- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}


- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}


- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
     
       代码说明
  • 此处定义UIApplication.上面的方法都是应用程序UI调用和不包含用户定义的方法。
  • UIWindow对象被分配用来保存应用程序分配对象
  • 调用makeKeyAndVisible能使窗口可见

         ViewController.h     
  
[Objective-C] 纯文本查看 复制代码
#import <UIKit/UIKit.h>

@interface ViewController : UIViewController


@end


       代码说明
  • ViewController类继承UIViewController,为iOS应用程序提供基本视图管理模型。
     

       ViewController.m
     
[Objective-C] 纯文本查看 复制代码
#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
   
      代码说明
  • 在这里两种方法实现UIViewController类的基类中的定义
  • 初始视图加载后调用viewDidKoad中的安装程序
  • 在内存警告的情况下会调用didReceviveMemoryWarning

      Main.storyboard

      这个默认就是程序的第一个视图界面 就是ViewController,在这里可以直接拖拽相关的控件进行视图布局。也可以在info.list 里面设置不用这个来启动主页面。用纯代码的方式启动应用程序。如下图。

      C542EF74346CB5E18EB4CD67CAD91354.png

     下一篇  Object-C atomic与nonatomic,assign,copy与retain的定义和区别







1. 开通SVIP会员,免费下载本站所有源码,不限次数据,不限时间
2. 加官方QQ群,加官方微信群获取更多资源和帮助
3. 找站长苏飞做网站、商城、CRM、小程序、App、爬虫相关、项目外包等点这里
 楼主| 发表于 2018-11-28 17:52:47 | 显示全部楼层
强烈支持楼主ing……
发表于 2018-11-28 17:58:25 | 显示全部楼层
我只是路过打酱油的。
发表于 2018-11-28 18:42:13 | 显示全部楼层
楼主大神支持你 强烈支持楼主ing……
您需要登录后才可以回帖 登录 | 马上注册

本版积分规则

QQ|手机版|小黑屋|手机版|联系我们|关于我们|广告合作|苏飞论坛 ( 豫ICP备18043678号-2)

GMT+8, 2024-4-26 21:44

© 2014-2021

快速回复 返回顶部 返回列表