ios学习笔记

原创 2012年03月21日 09:32:30

What is a bundle, you ask? Well, a bundle is just a special type of folder whose contents
follow a specific structure. Applications and frameworks are both bundles, and this call
returns a bundle object that represents our application.
One of the primary uses of NSBundle is to get to resources that you added to the
Resources folder of your project.
Those files will be copied into your application’s
bundle when you build your application. We’ve added resources like images to our
projects, but up to now, we’ve used those only in Interface Builder. If we want to get to
those resources in our code, we usually need to use NSBundle. We use the main bundle
to retrieve the URL of the resource in which we’re interested.

 

NSURL *plistURL = [bundle URLForResource:@"statedictionary"
withExtension:@"plist"];

This will return a URL containing the location of the statedictionary.plist file.

 

// image for ios

The first thing we do is load six different images. We do this using a convenience
method on the UIImage class called imageNamed:.
UIImage *seven = [UIImage imageNamed:@"seven.png"];
UIImage *bar = [UIImage imageNamed:@"bar.png"];
UIImage *crown = [UIImage imageNamed:@"crown.png"];
UIImage *cherry = [UIImage imageNamed:@"cherry.png"];

 

Once we have the six images loaded, we then need to create instances of UIImageView,
one for each image, for each of the five picker components. We do that in a loop.
for (int i = 1; i <= 5; i++) {
UIImageView *sevenView = [[UIImageView alloc] initWithImage:seven];
UIImageView *barView = [[UIImageView alloc] initWithImage:bar];
UIImageView *crownView = [[UIImageView alloc] initWithImage:crown];
UIImageView *cherryView = [[UIImageView alloc]
initWithImage:cherry];
UIImageView *lemonView = [[UIImageView alloc] initWithImage:lemon];
UIImageView *appleView = [[UIImageView alloc] initWithImage:apple];
After we have the image views, we put them into an array. This array is the one that will
be used to provide data to the picker for one of its five components.
NSArray *imageViewArray = [[NSArray alloc] initWithObjects:
sevenView, barView, crownView, cherryView,
lemonView, appleView, nil];

版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

IOS 学习笔记

  • 2015-08-06 11:20
  • 1.74MB
  • 下载

【iOS学习笔记】NSString 常用用法

//1、创建常量字符串。 NSString *astring = @"This is a String!";   //2、创建空字符串,给予赋值。 NSString *astring...

iOS学习笔记

  • 2014-12-21 22:31
  • 316KB
  • 下载

iOS学习笔记——视图上移与键盘弹回

在学习iOS开发的过程中总是遇见键盘出现时,遮盖了输出口UITextField,无法看到用户自己输出的内容。这时就需要对当前视图做出相应的上移,当输出结束时点击屏幕的任意地方,使键盘弹回去。 第一种...

ios学习笔记二--电影网

  • 2015-04-09 11:56
  • 3.35MB
  • 下载

ios学习笔记 --sqllite3

  • 2015-03-27 11:31
  • 126KB
  • 下载

iOS-Network学习笔记(一)——NSURLRequest/NSURLResponse

NSURLRequest,NSURLResponse 属性,解释

iOS学习笔记

  • 2016-06-01 09:54
  • 3.49MB
  • 下载
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)