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-25-2010, 10:38 PM   #1 (permalink)
Registered Member
 
Join Date: Dec 2010
Posts: 3
lightfoot218 is on a distinguished road
Cool initWithFrame is not working for my UIImageView

Hi! I am trying to position a UIImageView on my view. I initialized it programmatically. When I use initWithFrame, the UIImageView shows up, but at the top left corner of the screen instead of where I told it to be. I did tell the image within the UIImageView to be at the upper left corner, but that should be within the UIImageView, right? Here is my code:

This is where I initialize the UIImageView:
Code:
// Draw NADH
nadh = [[NadhView alloc] init:CGPointMake(300, 300)];
And here is the init method in my NadhView class:
Code:
- (id)init:(CGPoint)initialPoint {
	//Set frame and image
	self.image = [UIImage imageNamed:@"nadh.png"];
	self.drawPoint = initialPoint;
	CGRect rectangle = CGRectMake(drawPoint.x, drawPoint.y, image.size.width, image.size.height);
	
	//Make the view and draw the image
	[self initWithFrame:rectangle];
	CGPoint point = CGPointMake(0, 0);
	[image drawAtPoint:point];
	
    return self;
}
(NadhView is a subclass of UIImageView)

Any help would be appreciated. Thanks!
lightfoot218 is offline   Reply With Quote
Old 12-26-2010, 11:47 AM   #2 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

Code:
nadh = [[NadhView alloc] initWithFrame:CGRectMake(x,y,w,h)];
should work, if not debug and look a x,y,w,h if they are correct value.
__________________
dany_dev is offline   Reply With Quote
Old 12-26-2010, 02:44 PM   #3 (permalink)
Registered Member
 
Join Date: Dec 2010
Posts: 3
lightfoot218 is on a distinguished road
Default Needed to add imageview as subview

It turns out I was missing this:

Code:
[self addSubview:nadh];
lightfoot218 is offline   Reply With Quote
Reply

Bookmarks

Tags
initwithframe, 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: 387
8 members and 379 guests
chemistry, daudrizek, jeroenkeij, Kirkout, PavelMik, whitey99
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,665
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, daudrizek
Powered by vBadvanced CMPS v3.1.0

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