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];

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值