我不知道这是否可行,但我认为这是可能的,我不知道该怎么做。我只想从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];
}
}];
我的解析设置:
感谢。
答案 0 :(得分:16)
是的,这是可能的。如果使用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];
}
}];
}
}];