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 Development

Reply
 
LinkBack Thread Tools Display Modes
Old 03-13-2010, 06:19 AM   #1 (permalink)
Registered Member
 
Join Date: Mar 2010
Posts: 3
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
Old 03-13-2010, 01:42 PM   #2 (permalink)
Registered Member
 
Join Date: Mar 2010
Posts: 3
Default

I've been working under the theory that I'm actually grabbing the scrolling view, not the underlying text view, but I haven't found any way of grabbing it. If such a thing is feasible, is there a way to grab the under layer from UITextView?

thanks again!
oldmicah is offline   Reply With Quote
Reply

Bookmarks

Tags
renderincontext, uiimage, uilabel, uitextview

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: 256
20 members and 236 guests
14DEV, @sandris, ADY, ArtieFufkin10, bookesp, ckgni, Dani77, HemiMG, iDifferent, IphoneSdk, jakerocheleau, JasonR, MACralik, NSeven, prchn4christ, Rudy, silverwiz, spiderguy84
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,885
Threads: 89,230
Posts: 380,767
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 02:53 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0