ios - Turn FBProfilePictureView into UIImage -
i have facebook login gets users profilepicture, lblusername, , lblemail. know fbprofilepictureview uiview contains uiimageview.
so, asking how convert or "save" profilepicture facebook uiimage? here loginviewcontroller.m. have imported facebook sdk correctly in loginviewcontroller.h file.
#import "loginviewcontroller.h" #import <quartzcore/quartzcore.h> @interface loginviewcontroller () - (void)togglehiddenstate:(bool)shouldhide; @end @implementation loginviewcontroller - (void)viewdidload { [super viewdidload]; [self togglehiddenstate:yes]; self.lblloginstatus.text = @""; self.loginbutton.readpermissions = @[@"public_profile", @"email"]; self.loginbutton.layer.cornerradius = 0; [self.loginbutton.layer setborderwidth:0.0f]; self.loginbutton.delegate = self; // uiimageview *image = nil; // // (nsobject *pic in [self.profilepicture subviews]) { // if ([pic ismemberofclass:[uiimageview class]]) { // uiimageview *objimg = (uiimageview *)pic; // image = objimg.image; // break; // } // } // // self.view.backgroundcolor = [uicolor colorwithpatternimage:image]; // // additional setup after loading view. } -(void)togglehiddenstate:(bool)shouldhide{ self.lblusername.hidden = shouldhide; self.lblemail.hidden = shouldhide; self.profilepicture.hidden = shouldhide; self.loggedinwallpaper.hidden = shouldhide; self.fblogout.hidden = shouldhide; } -(void)toggleunhiddenstate:(bool)shouldshow{ self.loggedinwallpaper.hidden = no; } -(void)loginviewshowingloggedinuser:(fbloginview *)loginview{ self.lblloginstatus.text = @""; [self togglehiddenstate:no]; [self toggleunhiddenstate:yes]; } -(void)loginviewshowingloggedoutuser:(fbloginview *)loginview{ self.lblloginstatus.text = @""; [self togglehiddenstate:yes]; } -(void)loginviewfetcheduserinfo:(fbloginview *)loginview user:(id<fbgraphuser>)user{ nslog(@"%@", user); self.profilepicture.profileid = user.objectid; self.lblusername.text = user.name; self.lblemail.text = [user objectforkey:@"email"]; uistoryboard *storyboard = [uistoryboard storyboardwithname:@"main" bundle:nil]; uiviewcontroller *homeviewcontroller = (uiviewcontroller *)[storyboard instantiateviewcontrollerwithidentifier:@"homeviewcontroller"]; [self presentviewcontroller:homeviewcontroller animated:yes completion:nil]; // // (nsobject *obj in [self.profilepicture subviews]) { // if ([obj ismemberofclass:[uiimageview class]]) { // uiimageview *objimg = (uiimageview *)obj; // image = objimg.image; // break; // } // } } -(void)loginview:(fbloginview *)loginview handleerror:(nserror *)error{ nslog(@"%@", [error localizeddescription]); } - (void)didreceivememorywarning { [super didreceivememorywarning]; // dispose of resources can recreated. } #pragma mark - navigation // in storyboard-based application, want little preparation before navigation //- (void)prepareforsegue:(uistoryboardsegue *)segue sender:(id)sender { // uiimage *image = _profilepicture; // homeviewcontroller *homeviewcontroller = (homeviewcontroller *)segue.destinationviewcontroller; // homeviewcontroller.homepic = image; // // new view controller using [segue destinationviewcontroller]. // pass selected object new view controller. //} @end
i not use image since facebook load different sizes of image , don't know whether low quality version. can't download image in size need it?
facebook uses urls this: http://graph.facebook.com/user_id/picture?width=width&height=height
ofc need swap out user_id
user's facebook user id , width
, height
values need.
Comments
Post a Comment