在我发布解析后,我需要帮助将图片发布到tableview上。我正在使用解析和目标-c。我到了你可以发布图片的地方,我可以在解析时看到它,但是如何在我的应用程序或桌面视图中看到时间轴上的图片?
这是我发布到解析的代码,
- (IBAction)uploadButton:(id)sender{
NSData* data = UIImageJPEGRepresentation(_imageView.image, 100);
PFFile *imageFile = [PFFile fileWithName:@"Image.jpg" data:data];
// Save the image to Parse
[imageFile saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if (!error) {
// The image has now been uploaded to Parse. Associate it with a new object
PFObject* newPhotoObject = [PFObject objectWithClassName:@"PhotoObject"];
[newPhotoObject setObject:imageFile forKey:@"image"];
[newPhotoObject saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if (!error) {
NSLog(@"Saved");
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Success" message:@"Your picture has been successfully uploaded." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}
else{
// Error
NSLog(@"Error: %@ %@", error, [error userInfo]);
}
}];
}
}];
}
我还需要做些什么才能看到我在主的tableview页面上发布的内容?
我将视图控制器标记为“发布页面”和“主页面”。 “主页面”是我希望我发布的所有图片最终解析的地方,以及图片的评论部分。
答案 0 :(得分:-1)
我这样做了,可能对你有用。看一看
-(IBAction)btnUpDateImageClicked:(id)sender
{
if (UserSelectedImage)
{
HUDSHOWWITHTEXT(@"Updating profile");
PFQuery *query = [PFQuery queryWithClassName:User_Info];
NSLog(@"->%@",[PFUser currentUser].username);
[query whereKey:UserName equalTo:[PFUser currentUser].username];
[query getFirstObjectInBackgroundWithBlock:^(PFObject * user , NSError *error) {
if (!error) {
// Found User and modify it
PFFile *imageFile1,*imageFilePlaceHolder;
NSData *imageData1,*imageDataPlaceHolder;
// PFFile *fileDeleted = [[PFFile alloc] init];
if (UserSelectedImage) {
//User image
imageData1 = UIImageJPEGRepresentation(UserSelectedImage, 1.0);
imageFile1 = [PFFile fileWithName:@"img.png" data:imageData1];
[user setObject:imageFile1 forKey:@"user_image"];
//PlaceHolder
UIImage *imagPlaceholder = UserSelectedImage;
imagPlaceholder = [APP_DELEGATE SyncPlaceHolderImage:imagPlaceholder];
imageDataPlaceHolder = UIImageJPEGRepresentation(imagPlaceholder, 1.0);
imageFilePlaceHolder = [PFFile fileWithName:@"img.png" data:imageDataPlaceHolder];
[user setObject:imageFilePlaceHolder forKey:@"placeholder_image"];
}
else {
user[@"user_image1"] = [NSNull null];
user[@"placeholder_image"] = [NSNull null];
}
// Save
[user saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if (succeeded) {
HUDHIDE;
if (UserSelectedImage) {
APP_DELEGATE.user.pfImageOne = imageFile1;
APP_DELEGATE.user.pfImagePlaceHolder= imageFilePlaceHolder;
}
else {
APP_DELEGATE.user.pfImageOne = nil;
APP_DELEGATE.user.pfImagePlaceHolder=nil;
}
ShowAlert(@"Saved SUccesfully");
}
else
{
HUDHIDE;
ShowAlert(@"Problem updating profile-%@");
}
}];
} else {
// Did not find any UserStats for the current user
NSLog(@"Error: %@", error);
HUDHIDE;
ShowAlert(@"Problem updating profile")
}
}];
}
else
{
ShowAlert(@"please select Image");
}
}