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 03-13-2010, 05:19 AM   #1 (permalink)
oldmicah
Registered Member
 
Join Date: Mar 2010
Posts: 3
oldmicah is on a distinguished road
Default grabbing an UIImage from a UITextView or UILabel gives white rect

Hello all,

I need to grab an UIImage from a UITextView or UILabel. I've got a method that will pull an image successfully from other types of views ( [UIViewController view], MKMapView, UIButtons) but I am just getting a white rect for my UITextView.

I've been banging my head against the wall for a while and suspect something really, really basic.

many thanks!

Code:
@interface TaskAccomplishmentViewController : UIViewController {
	
    MKMapView *mapView;
	UILabel *timeLeftText;
	UITextView *challengeText;
	
	UIButton *successButton;

<snip>

-(void) setChallangeImageToImageFromChallenge {
	
	//  works
//	[currChallenge setChallengeImage:[UIImageUtils grabImageFromView:mapView]];
//	[currChallenge setChallengeImage:[UIImageUtils grabImageFromView:[self view]]];
//	[currChallenge setChallengeImage:[UIImageUtils grabImageFromView:successButton]];
	
	//doesn't work
//	[currChallenge setChallengeImage:[UIImageUtils grabImageFromView:timeLeftText]];
	[currChallenge setChallengeImage:[UIImageUtils grabImageFromView:challengeText]];
	
}
and the grabImageFrom a view code

Code:
+(UIImage *)grabImageFromView: (UIView *) viewToGrab {
	
	UIGraphicsBeginImageContext(viewToGrab.bounds.size);
	
	[[viewToGrab layer] renderInContext:UIGraphicsGetCurrentContext()];
	UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
	UIGraphicsEndImageContext();
	return viewImage;
}
oldmicah is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 175,539
Threads: 94,055
Posts: 402,653
Top Poster: BrianSlick (7,982)
Welcome to our newest member, cecilytw61
Powered by vBadvanced CMPS v3.1.0

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