Saving image to Documents directory and retrieving for email attachment

前端 未结 4 1467
遇见更好的自我
遇见更好的自我 2020-11-28 04:07

I having trouble figuring out NSBundle & DocumentDirectory data, I have a Camera Picture \"imageView\" that I\'m saving to the NSDocumentDire

4条回答
  •  伪装坚强ぢ
    2020-11-28 04:22

    Try this one :

     -(void)setProfilePic
    {
      NSArray *docpaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
      NSString *documentsDirectory = [docpaths objectAtIndex:0];
      NSString *imagePath = [documentsDirectory stringByAppendingPathComponent:@"Image.png"];
    
      NSData *imgData = [[NSData alloc] initWithContentsOfURL:[NSURL fileURLWithPath:imagePath]];
      UIImage *thumbNail = [[UIImage alloc] initWithData:imgData];
      [profilePic_btn setBackgroundImage:thumbNail forState:UIControlStateNormal];
    }
    

提交回复
热议问题