ios - Getting an image from UITextView -


any ideas on how image uitextview?

nsstring *string=@""; self.textview.text=string; uiimageview *image=[[uiimageview alloc]initwithframe:cgrectmake(0, 0, 320, 320)]; image.image=_textview.textcontainer; 

i thinking not right

nsstring *string=@"write text"; self.textview.text=string; uiimage *image = [self makeimagewithrect:self.textview.frame];// image rectangle textview  uiimageview *imageview=[[uiimageview alloc]init]; imageview.image=image;   -(uiimage*)makeimagewithrect:(cgrect)rect {   uigraphicsbeginimagecontext(self.view.bounds.size);   [self.view.layer renderincontext:uigraphicsgetcurrentcontext()];   uiimage *viewimage = uigraphicsgetimagefromcurrentimagecontext();  uigraphicsendimagecontext();   return viewimage; } 

/code saving image photo album/

/* save photo album */ uiimagewritetosavedphotosalbum(imagetosave ,                                self, // send message 'self' when calling callback                                @selector(thisimage:hasbeensavedinphotoalbumwitherror:usingcontextinfo:), // selector tell method call on completion                                null); // won't need contextinfo here);  [[[uialertview alloc] initwithtitle:@"app name" message:@"image saved photo album" delegate:nil cancelbuttontitle:@"ok" otherbuttontitles:nil, nil]show];  - (void)thisimage:(uiimage *)image hasbeensavedinphotoalbumwitherror:(nserror *)error usingcontextinfo:(void*)ctxinfo { if (error) {     // needed handle error or display user } else {     // .... want here handle     // .... when image has been saved in photo album } } 

here code use saving snapshot of whole screen

- (ibaction)saveaction:(id)sender {  uiview* captureview = self.containerview;  /* capture screen shoot @ native resolution */ uigraphicsbeginimagecontextwithoptions(captureview.bounds.size, captureview.opaque, 0.0); [captureview.layer renderincontext:uigraphicsgetcurrentcontext()]; uiimage * screenshot = uigraphicsgetimagefromcurrentimagecontext(); uigraphicsendimagecontext();  /* render screen shot @ custom resolution */ cgrect croprect = self.view.frame; uigraphicsbeginimagecontextwithoptions(croprect.size, captureview.opaque, 1.0f); [screenshot drawinrect:croprect]; uiimage * customscreenshot = uigraphicsgetimagefromcurrentimagecontext(); uigraphicsendimagecontext();  uiimage *imagetosave =[uiimage imagewithcgimage:[customscreenshot cgimage]                     scale:1.0               orientation: uiimageorientationup];  /* save photo album */ uiimagewritetosavedphotosalbum(imagetosave ,                                self, // send message 'self' when calling callback                                @selector(thisimage:hasbeensavedinphotoalbumwitherror:usingcontextinfo:), // selector tell method call on completion                                null); // won't need contextinfo here);  [[[uialertview alloc] initwithtitle:@"app name" message:@"image saved photo album" delegate:nil cancelbuttontitle:@"ok" otherbuttontitles:nil, nil]show]; }  - (void)thisimage:(uiimage *)image hasbeensavedinphotoalbumwitherror:(nserror *)error usingcontextinfo:(void*)ctxinfo { if (error) {     // needed handle error or display user } else {     // .... want here handle     // .... when image has been saved in photo album } } 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -