iOS5编程--官方例子代码的研究--1.HelloWorld

笨鸟学iOS开发(1)HelloWorld源码 立即下载

官方描述:

HelloWorld demonstrates how to use a keyboard to enter text into a text field and how to display the text in a label.

适用级别:

入门级

这个是最初级的一个例子代码,所以做为第一个研究的对象,如果你是一个有一定工作经验的开发人员,请忽略之。

这个工程中需要注意以下几个地方。

1.这个工程是一个Empty Application工程,不是一个Single View Application工程,虽然运行后看起来象一个Single View Application工程,

2.创建一个Empty Application工程后,手动加入一个MyViewController类,继承自UIViewController,同时需要选中With XIB for user interface。你自己做的时候会发现生成的文件目录和例子中不同,请忽略这个,例子是Xcode的历史版本生成的。

3.在例子中,类名是MyViewController,xib文件的名字是HelloWorld.xib,在我们自己创建的工程中,类名和xib文件的名字相同。我们的方式会更方便一些。

当然我们需要改写HelloWorldAppDelegate类中的函数applicationDidFinishLaunching中的第一行

MyViewController *aViewController = [[MyViewControlleralloc] initWithNibName:@"HelloWorld"bundle:[NSBundlemainBundle]];

更改为

MyViewController *aViewController = [[MyViewControlleralloc] initWithNibName:@"MyViewController"bundle:[NSBundlemainBundle]];

4.如果你使用了分别创建类和xib文件,类名为MyViewController,而xib文件名为HelloWorld.xib,那么必须自己修改xib文件。打开HelloWorld.xib,


选择File's Owner,在Utility area部分选择Identity inspector,在Custom Class下面修改Class中的内容,修改为MyViewController,这样的话,HelloWorldAppDelegate类中的函数applicationDidFinishLaunching中的第一行就不需要再修改了。

在Utility area上选择Attributes部分,Simulated Metrics里面的Status Bar上,选择None.

右键点击View上,选择New Referencing Outlet后面的圆点,拖拽到File's Owner上松手后,点击出现的view,保存xib文件即可。


5.在上面的xib中的view上添加三个控件,一个是Image view,一个Label,一个是Text Field,同时为后两个添加IBOutlet的指针。

关于添加IBOutlet的指针,在Xcode4.0中有了新的方式。过去的方式,我就不在这里介绍了,比较的麻烦。



确保Assistant Editor区域出现,并且是MyViewController.h文件的内容。

在Text Field上点击右键,点中New Reference Outlet后面的圆点,拖拽到Assistant Editor区域的MyViewController类的声明中,松开后,在弹出对话框中输入textField,回车即可。

同样的方式也可以快速设置IBAction。

6.在HelloWorldAppDelegate中的applicationDidFinishLaunching函数中:

[[UIApplicationsharedApplication] setStatusBarStyle:UIStatusBarStyleBlackOpaque];


这行代码是设置iOS设备的状态栏在程序运行起来后的呈现方式的,这样设置是呈现为黑色底。缺省的灰色底。

7.UITextFieldDelegate的使用

Text Field在输入模式下,按回车,软键盘并不会消失,需要我们实现UITextFieldDelegate中的一个函数,并设置所有在viewcontroller中的Text Field的代理都是这个viewcontroller。

- (BOOL)textFieldShouldReturn:(UITextField *)theTextField {

[theTextFieldresignFirstResponder];

returnYES;

}

这个函数在键盘消失的时候会被调用。

8.例子程序中,点击界面上任何其他地方,软键盘也会消失,这个就是下面这个函数起的作用

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event

{

   // Dismiss the keyboard when the view outside the text field is touched.

    [textFieldresignFirstResponder];

   // Revert the text field to the previous value.

   textField.text =self.string; 

    [supertouchesBegan:touches withEvent:event];

}


任何view,viewcontroller都可以重写下面四个函数来响应手指事件。

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;

- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event;


当然在iOS3.2后,增加了更多的手指事件。


HelloWorld_iOS:iOS设备的Hello World源代码-Source code world HelloWorld_iOS iOS设备的Hello World源代码 这是用Swift编写的,应该可以在iOS设备上使用 立即下载

相关推荐

Cadence仿真数字电路功耗

Cadence仿真数字电路功耗 数字电路的功耗采用平均电流乘电源电压获得,所以本文的关键是测量平均电流。 仿真前设置好仿真参数后,在仿真的ADE街边选择:outputs➡to be saved➡select on design 选择电源的负端电流(若选择正端,则电流为负): 选择完成后,在ADE界面讲所选节点的plot也勾选上,点击run。仿真完成后自动显示波形。在波形上选中该电流曲线,右击选择:send to➡calculator 注意上图中,商店前的波形不稳定,需要进行截取。在calculator

qq_41519780的博客 1万+

Xcode4.3开发第一个IOS应用实例

关于如何创建第一个 iOS 应用 本篇“第一个 iOS 应用”教程将向你介绍 iOS 应用开发中的“三个T”: Tools(工具)如何利用 Xcode 创建和管理工程。 Technologies(技术)如何创建能够响应用户输入的应用。 Techniques(技巧)如何充分利用 iOS 应用开发的基础设计模式。 当你完成本教程的所有步骤之后,你的应用看起来会和下边图

嘀咕的榔头 2万+

Godot 4.x 实现 JRPG 回合制战斗系统:架构、状态机与实战优化

游戏开发中,状态机是管理复杂逻辑流转的核心设计模式,尤其在回合制战斗这类事件驱动的场景中。其原理是通过定义有限的状态和明确的转移条件,来控制系统在不同阶段的行为,从而实现清晰、可维护的流程控制。这项技术的价值在于能够将杂乱的条件判断代码结构化,降低模块间的耦合度,提升代码的可读性和可扩展性。在游戏开发领域,状态机广泛应用于角色AI、UI流程、战斗系统等场景。本文以Godot引擎为例,深入探讨如何运用节点与信号驱动架构,构建一个健壮的JRPG(日式角色扮演游戏)回合制战斗系统。内容涵盖从核心的**状态机**设

weixin_33749242的博客 506

最简单的基于FFmpeg的移动端例子:IOS HelloWorld

本文记录IOS平台下基于FFmpeg的HelloWorld程序。该示例C语言的源代码来自于《最简单的基于FFMPEG的Helloworld程序》。相关的概念就不再重复记录了。IOS程序使用FFmpeg类库的说明IOS应用程序使用FFmpeg类库的流程如下所示。1. 编译FFmpeg类库编译IOS的FFmpeg类库需要支持5种架构:armv7、armv7s、arm64、i386、x86_64。其中前

雷霄骅(leixiaohua1020)的专栏 4万+

SPSS&Mplus—共同方法偏差(Common Method Bias)控制与检验

共同方法偏差(Common Method Bias)的控制方法:程序控制(Procedural)和统计控制(Statistical)。

m0_54401011的博客 1万+

使用pytorch构建LSTM_AE模型的两种方式

2.基本LSTM_Unit计算——基本LSTM_AE结构 3.自定义LSTM_Unit计算——自定义LSTM_AE结构 1.LSTM-Encoder-Decoder模型结构及简要解析 图基本lstm计算单元

qq_37840762的博客 7286

iOS7初体验(1)——第一个应用程序HelloWorld

iOS7 Beta已经发布了,迫不及待地下载了iOS 7及Xcode 5并体验了一下。先做一个简单的Hello World看看都有哪些变化吧。 1. 启动Xcode5-DP; 2. 从菜单选择File-New Project...,弹出如下窗口: 注意,在此多了一个SpriteKit Game的模板,暂时先不管它,还是选择熟悉的Single View Application,然后单击

大石头的程序空间 1万+

Python实战:用Realsense D435和睿尔曼机械臂完成手眼标定的5个关键步骤

本文详细介绍了使用Python、Realsense D435深度相机与睿尔曼机械臂进行手眼标定的完整实战流程。文章将过程拆解为环境搭建、数据采集、核心计算、结果验证和精度优化五个关键步骤,重点剖析了数据采集的黄金法则、常见错误排查以及如何将标定结果集成到视觉抓取程序中,旨在帮助开发者实现毫米级精度的视觉引导机器人系统。

weixin_29103191的博客 326

iOS之HelloWorld及XCode开发平台

经过一番折腾,终于在Windows平台下搭建了

chiyiw 的博客 795

rv1126 读取sensor输入,输出到屏幕显示【RK_MPI API接口】

rv1126 libdrm VO

学习记录 1万+

YOLO26涨点改进 | 小目标损失函数独家改进篇 | TGRS 2025 | 引入AdaFocalLoss损失函数,改进小目标检测,自适应聚焦小目标与样本分布不平衡,提升检测精度与训练稳定性

目录一、前言:YOLO26原生损失函数在小目标检测中的核心痛点(涨点瓶颈)1.1 小目标权重不足,聚焦能力薄弱1.2 样本分布不平衡适配性差,正负样本权重失衡1.3 训练不稳定,易出现梯度消失/震荡1.4 未区分小目标与背景的冗余干扰,误检率高二、TGRS 2025顶刊灵感解析:自适应聚焦损失的核心逻辑三、全网独家创新:AdaFocalLoss损失函数设计与YOLO26适配(核心重点,可复现)3.1 AdaFocalLoss函数整体设计(独家设计,清晰可复现)3.2 各核心模块详细设计(独家创新,可直接复现

qq_36130719的博客 214

最简单的基于FFmpeg的移动端例子 IOS HelloWorld

最简单的基于FFmpeg的移动端例子 IOS HelloWorld

hffgjh的博客 482

Python爬虫教程:抓取短视频平台数据(以抖音和快手为例)

为什么抓取短视频平台数据?内容分析:通过抓取短视频平台上的视频内容、标题、标签等数据,可以进行内容分类、趋势分析、话题分析等。情感分析:抓取视频的评论数据,并进行情感分析,帮助企业或组织了解公众的情绪反馈。用户行为分析市场监测:通过抓取特定关键词或标签下的视频数据,分析市场趋势,进行竞争对手分析。短视频平台数据类型:视频信息:包括视频标题、描述、标签、作者等。用户信息:包括用户的昵称、粉丝数、关注数等。互动数据评论数据:视频下的用户评论内容及用户信息。

2201_76125261的博客 3675

IOS Theos Tweak 之 HelloWorld

玩Ios难点在哪?不在于Arm汇编,而在于没有设备。你起码得需要一个Mac电脑和Iphone。不建议装黑苹果,升级和鼓捣太麻烦了。某鱼搞个二手Mac Pro最低有2k的, Iphone搞个6或者6s, 有3-400的。Mac电脑系统起码要能装10.14.x。Iphone要无锁的,最好国行,系统就所谓了,最好低点 13以下。这样 Xcode 11.3也能玩。醉后不知天在水,满船清梦压星河。

m0_59598029的博客 334

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

IOS之helloworld

IOS之helloworld   写在前面 第一个iphone程序helloworld ios sdk介绍 修改ios工程属性   写在前面 一直对移动平台比较感兴趣,并且公司有兴趣小组,所以就报了IOS,本来就是搞java的所以android的新鲜感没有IOS强,事实就是这样的,公司没有一个报android兴趣小组的。。。学习IOS一段时间了,应该把学习中的点点滴

tfy1332的专栏 1161

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

IOS HelloWorld

iOS7 Beta已经发布了,迫不及待地下载了iOS 7及Xcode 5并体验了一下。先做一个简单的Hello World看看都有哪些变化吧。 1. 启动Xcode5-DP; 2. 从菜单选择File-New Project...,弹出如下窗口:注意,在此多了一个SpriteKit Game的模板,暂时先不管它,还是选择熟悉的Single View Application,然后单击Next按钮

Not In System 703

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

iOS-C语言-C语言的介绍以及第一个例子HelloWorld

0:c语言的发展历史,贝尔实验室发明了c语言 1:c语言的优缺点: 1.1:优点:  高效(可以直接访问内存,可以通过指针的方式直接操作内存) 可移植(linux系统的底层就是c语言编写的,Android 的底层就是Linux,linux 又是c语言的), 功能强大, 灵活 1.2:缺点: 程序漏洞较多, 难以理解,//相对于对象的java,难理解, 难以维护,//一堆方法

Kodulf的专栏 1378

IOS Helloworld

背景:想做一个打卡的APP,可是我只有很久以前玩过一点点oc,完全不具备此条件。   环境:Vmware12+MacOS10.11.5+iPhone 6 Plus   目标:先完成带界面的Helloworld.再写代码,调用远程接口。   步骤: 1、根据教程1(非常精准且非常基础)和教程2(非常新且非常全面,竟然还包括安装虚拟机),一步一步走。   2、一开始都非常顺利,唯一...

germmy-神一样的开发 198

iOS开发那些事--创建基于故事板的iOS 6的HelloWorld

基于故事板的HelloWorld工程 Storyboard(故事板)是用来替代xib的技术,也是iOS 5最重要的新特性之一。我们用Storyboard(故事板)重构HelloWorld。 使用故事板重构HelloWorld 勾选“Use Storyboards”项。 工程创建完成之后,通过导航进入MainStoryboard.storyboard   添加Label控件

「智捷课堂」关东升的博客 2193
上一篇: iOS5编程--官方例子代码的研究--序
下一篇: iOS5编程--官方例子代码的研究--2.UICatalog
NickTang
博客等级 码龄24年 261粉丝 49原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址