swift 第一个IOS应用程序
来源:互联网 发布:vasp软件安装 编辑:程序博客网 时间:2024/06/05 03:57
swift 出来也有一阵子了,一直没有时间来研究,简单的看了看,随手写几篇文章。特此声明:本博客纯属个人学习,有不足之处,属于正常,希望多多见谅.
第一个IOS应用程序开发
一.准备工作:
(1)Mac OS X操作系统 10.9.3,
(2)Xcode6.0,暂时我的Bt版本(有意外退出,和代码提示不全等现象)
二.本节涉及内容:
(1)变量和常量、函数、? !等符号的意义,简单的输出,IOS项目HellowroId
三.开始:
在这里就直接创建IOS项目了,在开发过程中遇到相关swift知识点在细谈,如图:
import UIKit
@UIApplicationMain
//class 在swift 中是声明一个类,在IOS项目中AppDelegate原来oc中的AppDelegate,应用程序的入口对象
class AppDelegate:UIResponder,UIApplicationDelegate
{
/*
var 声明变量关键字
window 是变量名
UIWindow 变量类型
? 可选类型在这里理解为空(nil)即可
*/
//声明一个全局变量
var window:UIWindow?
/*
关于swift 中变量和常量:
变量
var 声明变量关键字
var 声明没有类型,在变量的名字后面可以指定类型
如:
var i:Int = 3; // 声明一个int类型的变量,变量名字为 i变量的值为 3
常量:
let 常量声明关键字
let 声明没有类型,在变量的名字后面可以指定类型,常量的值是不可以改变的
如:
let d:Double =3.1415926;
d=3.5 //错误写法,因为常量的值是不可以改变的
*/
/*
函数:
swift 函数特点
(1)函数的参数中有标签(OC中的方法签名)
(2)函数的返回值在函数的尾部用指针符号(箭头)指向返回值类型
(3)函数声明关键字:func
*/
//第一个运行的入口函数,IOS生命周期那几个函数,可能会略有不同,你懂得,不懂后面说
func application(application:UIApplication, didFinishLaunchingWithOptions launchOptions:NSDictionary?) -> Bool
{
//UIWindow() 创建一个UIWindow对象 参数为 这个UIWindow的frame,下面我细说
self.window =UIWindow(frame:UIScreen.mainScreen().bounds)
// Override point for customization after application launch.
// ! 的意思是允许window==nil 时候运行,但是window==nil程序运行崩溃!
self.window!.makeKeyAndVisible()
// 声明一个color 常量(color 是一个对象), UIColor 类调用redCorlor()类方法
let color =UIColor.redColor();
//设置self.window的背景颜色
self.window!.backgroundColor = color;
//输出
println("Hellowrold IOS第一个项目");
/*
关于输出:
swift 的输出用 println
输出一个字符串Hellowrold
println("Hellowrold");
输出一个变量的值如:var f = 30.5
var f = 30.5
println("f=\(f)");
*/
returntrue
}
//下边以后在详细介绍
func applicationWillResignActive(application:UIApplication) {
// 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 throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
func applicationDidEnterBackground(application:UIApplication) {
// 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.
}
func applicationWillEnterForeground(application:UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
func applicationDidBecomeActive(application:UIApplication) {
// 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.
}
func applicationWillTerminate(application:UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
}
- swift 第一个IOS应用程序
- swift 第一个IOS应用程序
- 制作第一个 iOS 应用程序
- 第一个iOS应用程序开发
- 【原创】第一个iOS应用程序
- 【iOS学习】第一个iOS应用程序
- iOS 第一个项目(Swift语言)
- IOS第一个应用程序(HelloWorld)
- UI基础-01第一个iOS应用程序
- ios开发笔记 (1) 创建第一个ios 应用程序
- swift语言ios开发 第一个程序hello world!
- swift第一个ios项目,纯代码编程
- swift第一个iOS项目 纯代码编程(续)
- swift之第一个IOS程序(浏览web页面)
- 第一个swift程序
- 第一个swift程序
- 第一个swift程序
- IOS 入门开发之构建第一个应用程序(一)
- oracle实现远程连接超简单;枚举与剪枝();PowerDesigner生成数据库代码注意里面的双引号,应该去掉
- 操作时序的错误笔记(18B20)
- JHOST邀请码
- 第2次实验——算法基本功 与 综合思考
- 集合
- swift 第一个IOS应用程序
- java从头学day03-2[函数概述]
- CoreText -- 基础
- 使用运算符重载实现复数的四则运算
- sass和less,优秀的前端样式预处理器
- android:descendantFocusability用法简析
- 细数百度公司的知名开源项目
- 6/10无聊
- ios--swift完整教程