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

Mockup & CodeGen, iPhone & iPad
($9.99)

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

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

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

Reply
 
LinkBack Thread Tools Display Modes
Old 02-28-2009, 12:46 PM   #1 (permalink)
Registered Member
 
NickFalk's Avatar
 
Join Date: Oct 2008
Location: Oslo, Norway
Posts: 20
Default Displaying to a UIImageView from an object instance

Hi there. I'm finally finding the time to try my hand at some baby steps* in iPhone programming. I am currently working on a very simple dungeon crawler as this is something I've made a few times before on other platforms and in other languages.

I have a ViewController named "DungeonViewController" and I have a class named "Room". The idea is to have an instance of the Room.class displaying an image (or rather two) to an UIImageView in the DungeonView.xib.

I have made an object of the type Room in the xib-file and connected the outlet "floor" to the UIImageView in question. It is (obviously) not working however. Here are some code snippets:

Room.h
Code:
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

@interface Room : NSObject {
	IBOutlet UIImageView *floor;
}
@property (nonatomic, retain) UIImageView *floor;
-(void) displayRoomFloor:(id)sender;
@end
Room.m
Code:
#import "Room.h"
@implementation Room
@synthesize floor;

-(void)displayRoomFloor:(id)sender
{
	NSLog(@"displayRoomFloor");
			floor.animationImages = [NSArray arrayWithObjects: [UIImage imageNamed:@"floor1.png"],[UIImage imageNamed:@"floor2.png"], nil];
			floor.animationDuration = 0.2;
			floor.animationRepeatCount = 0;
		[floor startAnimating];
}@end
Now, the animation bit should work just fine as it does when it is included directly in my DungeonViewController/viewDidLoad. At the moment I'm trying to achieve the same thing by calling an instance of room like below:
Code:
-(void)viewDidLoad {
    [super viewDidLoad];	
	room = [[[Room alloc] init] autorelease];
		[room displayRoomFloor:self];
}
I know from the console that the call to the instance method is achieved but it is not displaying anything (or at least not doing so in a visible manner).

I believe I might have some misconception about the right way to hook this kind of stuff up? My idea is to use the Room-class to display graphical details for each room in a dungeon and as such it made sense to me that each room should actually be an object...

Anyone?
Anyone, actually understand what I'm writing right now? Not sure I do. Time to open up another bottle of beer. It's the best thing that doesn't help.



*I'm not quite sure how I manage to makes steps of any sort with my hands. Ah, the blessing of mixed metaphors...
NickFalk is offline   Reply With Quote
Old 03-04-2009, 03:40 PM   #2 (permalink)
Junior Bacon Cheeseburger
 
Join Date: Mar 2009
Location: maryland
Age: 27
Posts: 48
Send a message via AIM to yujean Send a message via MSN to yujean Send a message via Skype™ to yujean
Default

i would also like to know the solution to this, as i'm in the process of teaching myself how to not be a super noob.

for example, i do'nt know why his [room displayRoomFloor:self] takes in a parameter "self"

... bahh...
yujean is offline   Reply With Quote
Reply

Bookmarks

Tags
displaying, graphics, object instance, uiimageview

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: 272
21 members and 251 guests
ADY, AragornSG, Bertrand21, Dani77, Dattee, Duncan C, fkmtc, HDshot, HemiMG, iDifferent, JasonR, macquitzon216, mer10, prchn4christ, Rudy, sacha1996, sneaky, spiderguy84, Sunny46, theone8one
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,885
Threads: 89,231
Posts: 380,768
Top Poster: BrianSlick (7,129)
Welcome to our newest member, bookesp
Powered by vBadvanced CMPS v3.1.0

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