iphone - 从 parse.com 检索图像

标签 iphone ios image parsing

我不知道这是否可能,但我认为这是可能的,而且我不知道该怎么做。我只是想从 parse.com 加载图像,就像从 parse.com 检索对象一样。我应该像从 parse.com 获取字符串那样做吗?我刚刚找到了如何在解析时保存图像,但没有找到如何获取它们。如果有人可以向我展示执行此操作的链接或示例代码,我会很高兴。

我已经设置了一个从解析中检索的字符串:

PFQuery *query = [PFQuery queryWithClassName:@"app"];
[query getObjectInBackgroundWithId:@"ID"
                             block:^(PFObject *textdu, NSError *error) {
                                 if (!error) {



                                     UIFont *welcomeLabelFont = [UIFont boldSystemFontOfSize:17];

                                     welcomeLabel.text = [textdu objectForKey:@"ueberschriftnews"];
                                     welcomeLabel.font = welcomeLabelFont;
                                     welcomeLabel.textColor = [UIColor whiteColor];
                                     welcomeLabel.textAlignment = NSTextAlignmentCenter;
                                     welcomeLabel.backgroundColor = [UIColor clearColor];
                                     welcomeLabel.shadowColor = [UIColor blackColor];
                                     welcomeLabel.shadowOffset = CGSizeMake(0, 1);
                                     [contentView addSubview:welcomeLabel];



                                     // The get request succeeded. Log the score
                                     NSString *text = [textdu objectForKey:@"newstext"];
                                     UIFont *font = nil;
                                     CGFloat points = 17;
                                     CGFloat maxHeight = infoLabel.frame.size.height;
                                     CGFloat textHeight;
                                     do {
                                         font = [UIFont systemFontOfSize:points];
                                         CGSize size = CGSizeMake(infoLabelRect.size.width, 100000);
                                         CGSize textSize = [text sizeWithFont:font constrainedToSize:size lineBreakMode: NSLineBreakByWordWrapping];
                                         textHeight = textSize.height;
                                         points -= 1;
                                     } while (textHeight > maxHeight);
                                     infoLabel.text = text;
                                     infoLabel.numberOfLines = 9;
                                     infoLabel.font = font;
                                     infoLabel.textColor = [UIColor whiteColor];
                                     infoLabel.textAlignment = NSTextAlignmentCenter;
                                     infoLabel.backgroundColor = [UIColor clearColor];
                                     infoLabel.shadowColor = [UIColor blackColor];
                                     infoLabel.shadowOffset = CGSizeMake(0, 1);

                                     [infoLabel sizeToFit];
                                     [contentView addSubview:infoLabel];

                                 } else {

                                     infoLabel.text = @"something";
                                     [infoLabel sizeToFit];
                                     [contentView addSubview:infoLabel];
                                 }

                             }];

我的解析设置:

enter image description here

谢谢。

最佳答案

是的,这是可能的。如果您使用 Web 界面而不是字符串,您应该将 PFFile 指定为一种类型。如果您从您的 iOS 客户端上传图片,这里有一个解析 iOS 指南的链接如何做到这一点 https://parse.com/docs/ios_guide#files/iOS . 一旦你的图像在那里,你可以通过这种方式下载图像:

PFQuery *query = [PFQuery queryWithClassName:@"app"];
[query getObjectInBackgroundWithId:@"ID"
                         block:^(PFObject *textdu, NSError *error) {
{
     // do your thing with text 
     if (!error) {
          PFFile *imageFile = [textdu objectForKey:@"image"];
          [imageFile getDataInBackgroundWithBlock:^(NSData *data, NSError *error) {
              if (!error) {
                  UIImage *image = [UIImage imageWithData:data];
              }
          }];
     }
 }];

关于iphone - 从 parse.com 检索图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13690655/

相关文章:

iphone - 来自 Plist 的凭据匹配

php - 加密发送到 PHP Web 服务的数据

iphone - 在另一个 View Controller 中调用方法导致循环

ios - 使搜索栏和 uisearchDisplayController 看起来像普通的输入字段

ios - 背景图片大小 Sprite Kit Game

iphone - 处理大数字

javascript - 使用 css :hover to display an image on top of another one 时意外的闪烁效果

ios - 以编程方式在ios上调用手势

html - 在鼠标悬停时缩放选取框标记中的图像

image - hadoop文件系统(HDFS)可以存储视频类型的文件吗?