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

View Single Post
Old 02-28-2009, 11:46 AM   #1 (permalink)
NickFalk
Registered Member
 
NickFalk's Avatar
 
Join Date: Oct 2008
Location: Oslo, Norway
Posts: 20
NickFalk is on a distinguished road
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
 

» Advertisements
» Stats
Members: 175,634
Threads: 94,095
Posts: 402,796
Top Poster: BrianSlick (7,990)
Welcome to our newest member, nyoe
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 09:09 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.