ios学习笔记

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
上一篇Android Layout XML属性
下一篇object-c学习:description方法:
想对作者说点什么? 我来说一句

Objective-C 学习笔记

2014年06月29日 326KB 下载

ios游戏开发之cocos2d-oc笔记

2016年05月27日 259KB 下载

xamarin学习笔记A01下(ios环境的安装)

2017年05月14日 55.64MB 下载

xamarin学习笔记B02(ios程序启动了解)

2017年11月28日 354.34MB 下载

IOS新手入门学习资料

2013年02月27日 6.12MB 下载

ios学习笔记 --sqllite3

2015年03月27日 126KB 下载

没有更多推荐了,返回首页

关闭
关闭