Subscribe ( )

iPhone Programming Tutorials

 

Forum

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

You must be logged in to post Login Register

Search 

create uiimageView for 15X8 board

User Post

1:16 am
March 19, 2009


antilantil

iCoder

posts 6

1

hi,

i am developing a game in which i have a 15X8 board .i want to place some uiimageview objects at some position of the board depending on the level. previously i created objects like 

UIImageView *view1;
UIImageView *view2;
.
.
UIImageView *view120;

and assign them in a static array
NSArray *array=[[NSArray alloc] initwithObjects:view1,view2,…..view120];

but it seems like so odd writing so many lines repeatedly.I want to create these UIImageView objects using loop and want to place these objects in a array. Help me to come out of this.

5:56 am
March 19, 2009


iphone_developer2008

Noob

PAK

posts 1

2

Hi Friend,

Which approach you are going to use , I've tried to implement with same way but fail , I don't know what was the cause behind this. But you can use this approach

UIImageView *image1;
UIImageView *image2;
.
.
UIImageView *imageN;

NSArray *array=[[NSArray alloc] initwithObjects:@”imageName1.png”,@”imageName2.png”,…..@”imageNameN.png”,nil];

Now try this to access imagesNames from the array where you need to image object:

image1.image = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[array objectAtIndex:0]]];

OR

UIImage *firstImag = [UIImage imageNamed:[array objectAtIndex:0]];

image1.image = [[UIImageView alloc] initWithImage:firstImage];

.

.

.

.

UIImage *NthImage = [UIImage imageNamed:[array CoolbjectAtIndex:N]];

imageN.image = [[UIImageView allCoolc] initWithImage:NthImage];


EnjCooly it man.

Regards!

Aamir Ali

iPhone Application Developer



About the iCodeBlog forum

Currently Online:

6 Guests

Maximum Online: 25

Forums:

Groups: 2

Forums: 6

Topics: 293

Posts: 729

Members:

There are 624 members

There are 1 guests


Brandon has made 87 posts

Top Posters:

bobcubsfan - 53

crazyiez - 30

VertigoSol - 26

AdeC - 17

Uhu - 17

Administrator: Brandon | Moderators: VertigoSol


© - Version 3.1.4 (Build 357)