Subscribe ( )

iPhone Programming Tutorials


 

Forum

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 9

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


Aamir Ali

Search 

About the iCodeBlog forum

Most Users Ever Online:

44


Currently Online:

4 Guests

Forum Stats:

Groups: 2

Forums: 6

Topics: 419

Posts: 893

Membership:

There are 934 Members

There has been 1 Guest

There are 2 Admins

There is 1 Moderator

Top Posters:

bobcubsfan – 54

crazyiez – 30

Uhu – 17

AdeC – 17

Nick – 15

jitesh61 – 12

Administrators: Brandon (88 Posts), Collin (0 Posts)

Moderators: VertigoSol (26 Posts)



©   

  • Posted by on 6 Aug 2008 in Uncategorized
  •   |  
  •   |  
  •   |  
  • Comments Off

Comments are closed.