Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 12-30-2010, 08:37 PM   #26 (permalink)
Just Some Guy
 
Join Date: Dec 2010
Posts: 112
UnretroGamer is on a distinguished road
Lightbulb

Quote:
Originally Posted by BrianSlick View Post
You probably aren't getting an image. Try using imageNamed: instead of the file one. I think that one needs a path.
OH MAN THAT DID SOMETHING!!!! Now there's an image (that I didn't create in Interface Builder) there. Only one, but I'm assuming that its just all 100 piled on top of each other. Maybe something is wrong with how I set the position? Woo! I feel so much closer!
UnretroGamer is offline   Reply With Quote
Old 12-30-2010, 08:40 PM   #27 (permalink)
Reading the Documentation
 
baja_yu's Avatar
 
Join Date: Sep 2010
Location: 45.255019,19.844908
Posts: 5,414
baja_yu has a spectacular aura about
Default

Use NSLog again and see what the values are used when you set the frame of the generated imageviews.
baja_yu is offline   Reply With Quote
Old 12-30-2010, 08:41 PM   #28 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

Well, your origin values are both based on .x. I assume one of those should be based on .y.

How much space do you have available? 128 is a sizable distance on an iPhone, maybe the others are off screen. Try 5 and see what happens.
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 12-30-2010, 08:47 PM   #29 (permalink)
Just Some Guy
 
Join Date: Dec 2010
Posts: 112
UnretroGamer is on a distinguished road
Default

Quote:
Originally Posted by baja_yu View Post
Use NSLog again and see what the values are used when you set the frame of the generated imageviews.
Alright I did just that by doing

Code:
CGRect blockFrame = block[blockX][blockY].frame; //create a frame
			blockFrame.origin =  CGPointMake(island.center.x + (128 * blockX), island.center.y + (128 * blockY)); //assign the frame the desired coordinates of this UIImageView
			block[blockX][blockY].frame = blockFrame; //assign the UIImageView the properties of the blockFrame I made
			NSLog(@"block[%d][%d]'s frame is now set to %d", blockX, blockY, block[blockX][blockY].frame);
a chunk of the NSLog looks like this:

2010-12-30 22:45:27.636 Primal[12205:207] 2
2010-12-30 22:45:27.637 Primal[12205:207] block[9][6]'s frame is now set to 1151598592
2010-12-30 22:45:27.637 Primal[12205:207] Loop [9][6] finished
2010-12-30 22:45:27.637 Primal[12205:207] 0
2010-12-30 22:45:27.637 Primal[12205:207] block[9][7]'s frame is now set to 1151598592
2010-12-30 22:45:27.638 Primal[12205:207] Loop [9][7] finished
2010-12-30 22:45:27.638 Primal[12205:207] 1
2010-12-30 22:45:27.638 Primal[12205:207] block[9][8]'s frame is now set to 1151598592
2010-12-30 22:45:27.638 Primal[12205:207] Loop [9][8] finished
2010-12-30 22:45:27.639 Primal[12205:207] 1
2010-12-30 22:45:27.639 Primal[12205:207] block[9][9]'s frame is now set to 1151598592
2010-12-30 22:45:27.639 Primal[12205:207] Loop [9][9] finished
UnretroGamer is offline   Reply With Quote
Old 12-30-2010, 08:53 PM   #30 (permalink)
Just Some Guy
 
Join Date: Dec 2010
Posts: 112
UnretroGamer is on a distinguished road
Default

Quote:
Originally Posted by BrianSlick View Post
Well, your origin values are both based on .x. I assume one of those should be based on .y.

How much space do you have available? 128 is a sizable distance on an iPhone, maybe the others are off screen. Try 5 and see what happens.
Yeah the images are 128px x 128px but a couple fit on the screen at once. Yeah that was a typo I didn't notice, I changed it to .y and now where that special block was? its now lower, I'd assume by 128px. There has to be something wrong with my formula for calculating its position. Which is now set like this:

Code:
CGRect blockFrame = block[blockX][blockY].frame; //create a frame
blockFrame.origin =  CGPointMake(island.center.x + (128 * blockX), island.center.y + (128 * blockY)); //assign the frame the desired coordinates of this UIImageView
block[blockX][blockY].frame = blockFrame; //assign the UIImageView the properties of the blockFrame I made
island is 128x128 UIImageView I placed in Interface Builder and is in the dead center of the view. I don't mind it being overlapped.

I'll know this code works correctly when I see squares surrounding island below and to the right, that weren't placed in Interface Builder.
UnretroGamer is offline   Reply With Quote
Old 12-30-2010, 08:56 PM   #31 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

Code:
NSLog(@"block[%d][%d]'s frame is now set to %@", blockX, blockY, NSStringFromCGRect(block[blockX][blockY].frame));
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 12-30-2010, 09:02 PM   #32 (permalink)
Just Some Guy
 
Join Date: Dec 2010
Posts: 112
UnretroGamer is on a distinguished road
Default

Quote:
Originally Posted by BrianSlick View Post
Code:
NSLog(@"block[%d][%d]'s frame is now set to %@", blockX, blockY, NSStringFromCGRect(block[blockX][blockY].frame));
Here's a chunk of the NSLog with that:

2010-12-30 22:59:45.261 Primal[12421:207] 1
2010-12-30 22:59:45.261 Primal[12421:207] block[9][4]'s frame is now set to {{1312, 944}, {128, 128}}
2010-12-30 22:59:45.261 Primal[12421:207] Loop [9][4] finished
2010-12-30 22:59:45.261 Primal[12421:207] 2
2010-12-30 22:59:45.262 Primal[12421:207] block[9][5]'s frame is now set to {{1312, 1072}, {128, 128}}
2010-12-30 22:59:45.262 Primal[12421:207] Loop [9][5] finished
2010-12-30 22:59:45.262 Primal[12421:207] 1
2010-12-30 22:59:45.262 Primal[12421:207] block[9][6]'s frame is now set to {{1312, 1200}, {128, 128}}
2010-12-30 22:59:45.263 Primal[12421:207] Loop [9][6] finished
2010-12-30 22:59:45.263 Primal[12421:207] 2
2010-12-30 22:59:45.263 Primal[12421:207] block[9][7]'s frame is now set to {{1312, 1328}, {128, 128}}
2010-12-30 22:59:45.264 Primal[12421:207] Loop [9][7] finished
2010-12-30 22:59:45.264 Primal[12421:207] 1
2010-12-30 22:59:45.264 Primal[12421:207] block[9][8]'s frame is now set to {{1312, 1456}, {128, 128}}
2010-12-30 22:59:45.264 Primal[12421:207] Loop [9][8] finished
2010-12-30 22:59:45.265 Primal[12421:207] 0
2010-12-30 22:59:45.265 Primal[12421:207] block[9][9]'s frame is now set to {{1312, 1584}, {128, 128}}
2010-12-30 22:59:45.265 Primal[12421:207] Loop [9][9] finished


Now I see two images (I'm guessing the top-left corner of the 100UIImageViews) a little offset from the island. I'm assuming it's because the anchor point of all the programmatic UIImageViews is on their top-left. How do I set their anchor points to their center?

P.S. SO CLOSE!!!
UnretroGamer is offline   Reply With Quote
Old 12-30-2010, 09:09 PM   #33 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

It's not the anchor point, it is the structure of a CGRect. It contains an origin and a size. The origin is at the top left.

UIViews (and thus, subclasses) have a center property. Instead of messing with the frame, you can just mess with the center.

Still... 1312 and higher... you're way off screen even on an iPad.
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 12-30-2010, 09:15 PM   #34 (permalink)
Just Some Guy
 
Join Date: Dec 2010
Posts: 112
UnretroGamer is on a distinguished road
Talking Working! Thank you so much!

Quote:
Originally Posted by BrianSlick View Post
It's not the anchor point, it is the structure of a CGRect. It contains an origin and a size. The origin is at the top left.

UIViews (and thus, subclasses) have a center property. Instead of messing with the frame, you can just mess with the center.

Still... 1312 and higher... you're way off screen even on an iPad.
Don't worry that's kind of the point. I'm generating a map for the player to discover, the whole world isn't supposed to fit on the screen.

So I set the block[blockX][blockY].center = blockFrame.origin; like you said and voila! The code does exactly what I wanted it to do! Thank you SOOooo much for your help! Both of you, I learned a lot. You guys are awesome.
UnretroGamer is offline   Reply With Quote
Reply

Bookmarks

Tags
arc4random(), cgpoint, crash, uiimage

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 362
9 members and 353 guests
akphyo, blueorb, fredidf, iAppDeveloper, iGamesDev, Kirkout, MarkC, mottdog, Touchmint
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,667
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, host number one
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 03:28 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0