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 02-01-2011, 04:10 PM   #1 (permalink)
Registered Member
 
Join Date: Jan 2011
Posts: 17
MichaelK1985 is on a distinguished road
Default Changing UIImage to UILabel?

I would have a text that I wanna display in a detailviewcontroller. I followed a tutorial but this is a UIImage and I want it to change it in a UILabel.

StedenNamen.m
Code:
#import "StedenNamen.h"

@implementation StedenNamen

@synthesize books;
@synthesize bookImages;

- (id) init {
	self = [super init];
	NSMutableArray *tmpBooks = [[NSArray alloc] initWithObjects:
								@"Aalst", 
								@"Aardenburg", 
								@"Aarle-Rixtel",
								@"Achterveld",
								@"Achtmaal",
								@"Aerdt",
								@"Zwolle",
								nil];
	self.books = tmpBooks;
	[tmpBooks release];
	
	NSMutableArray *tmpImages = [[NSArray alloc] initWithObjects:
								 @"Plaatsnaam", 
								 @"Plaats 2", 
								 @"Plaats 3", 
								 nil];
	self.bookImages = tmpImages;
	[tmpImages release];
	return self;
}

- (int)getNumberOfBooks {
	return [books count];
}

- (NSString *)getBookTitleAtIndex:(int)index {
	return [books objectAtIndex:index];
}


- (UIImage *)getBookImageAtIndex:(int)index {
	UIImage *bookImage = [UIImage imageNamed:[bookImages objectAtIndex:index]];
	return bookImage;
}

- (void) dealloc {
	[books release];
	[bookImages release];
	[super dealloc];
}

@end
DetailViewController.h

Code:
#import <UIKit/UIKit.h>

@class StedenNamen;

@interface StedenDetailViewController : UIViewController {
	UIImageView *bookImageView;
	StedenNamen *booksModel;
	
	int bookIndex;

}

@property (nonatomic, retain) IBOutlet UIImageView *bookImageView;
@property (nonatomic, retain) StedenNamen *booksModel;

- (void)setIndexForBookImage:(int)index;


@end
DetailViewController.m
Code:
#import "StedenDetailViewController.h"
#import "StedenNamen.h"

@implementation StedenDetailViewController

@synthesize bookImageView;
@synthesize booksModel;


- (void)setIndexForBookImage:(int)index {
	bookIndex = index;
}


- (void)viewWillAppear:(BOOL)animated {
	bookImageView.image = [booksModel getBookImageAtIndex:bookIndex];
    [super viewWillAppear:animated];
}


- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc. that aren't in use.
}

- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


- (void)dealloc {
	[bookImageView release];
	[booksModel release];
    [super dealloc];
}


@end
Is this possible?
MichaelK1985 is offline   Reply With Quote
Reply

Bookmarks

Tags
change, tableview, uiimage, uilabel, xib

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
14 members and 348 guests
7twenty7, blasterbr, Clouds, dre, EvilElf, jeroenkeij, jimmyon122, Mah6447, Morrisone, n00b, pungs, Sami Gh, stanny, toon4413
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,667
Threads: 94,121
Posts: 402,900
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:46 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0