uiimageview - iOS imageView only show part of the image -


i'm trying take photo using iphone camera , save both document folder , photo album , load image in scene. here code:

for image saving (in scene a):

- (void)imagepickercontroller:(uiimagepickercontroller *)picker didfinishpickingmediawithinfo:(nsdictionary *)info {      uiimage *chosenimage = info[uiimagepickercontrollereditedimage];     self.imageview.image = chosenimage;      [picker dismissviewcontrolleranimated:yes completion:null];      nsstring *mediatype = info[uiimagepickercontrollermediatype];      if ([mediatype isequaltostring:(nsstring *)kuttypeimage]) {          nsstring *filename = [nsstring stringwithformat:@"%@.png", self.patientmrn];         nsurl *urlsave = [[self getdocumentspathurl] urlbyappendingpathcomponent:filename];          [uiimagepngrepresentation(chosenimage) writetofile:urlsave.path atomically:yes];          uiimagewritetosavedphotosalbum(chosenimage, nil, nil, nil);      }  } 

and image loading (in scene b):

-(void)loaddefaultimage {     nsstring *filename = [nsstring stringwithformat:@"%@.png", self.patientmrn];     nsurl *urlimage = [[self getdocumentspathurl] urlbyappendingpathcomponent:filename];      if ([[nsfilemanager defaultmanager] fileexistsatpath:urlimage.path]) {     nsdata *datafile = [[nsfilemanager defaultmanager] contentsatpath:urlimage.path];     uiimage *image = [[uiimage alloc] initwithdata:datafile];      self.imageview.contentmode = uiviewcontentmodescaleaspectfill;     self.imageview.autoresizingmask =     ( uiviewautoresizingflexiblebottommargin      | uiviewautoresizingflexibleheight      | uiviewautoresizingflexibleleftmargin      | uiviewautoresizingflexiblerightmargin      | uiviewautoresizingflexibletopmargin      | uiviewautoresizingflexiblewidth );     self.imageview.image = image;     }     else {        nslog(@"image not found");     } } 

now have 2 problems.

  1. in scene a, have uiimageview set height , width constraints. below uiimageview have 2 buttons, 1 take photo , 1 going back. after taking photo , choose use photo, it'll go scene , display captured image in uiimageview. however, image displayed got big partially overlaps 2 buttons beneath it, if constraints set doesn't work @ all. why happen?

  2. in scene b, have smaller uiimageview used display photo took earlier. however, part of original image shown in scene b's imageview. tried set contentmode uiviewcontentmodescaleaspectfill , set autoresizingmask, still doesn't work. go wrong?

edit:

the problem solved! after dragged uiimageview storyboard, resize fit screen, forgot add height , width constraints it. add constraints, image displayed expected. thank guys.

have tried set not contentmode property, clipstobounds?

self.imageview.contentmode   = uiviewcontentmodescaleaspectfill; self.imageview.clipstobounds = yes; 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -