【发布时间】:2014-04-18 17:47:19
【问题描述】:
我需要创建一个 View 或 ImageView,无需重大 App Store 更新即可从计算机远程更新。所以基本上,它需要能够通过互联网浏览器或命令行工具进行更改。因此,例如今天我可以拥有一张图片,并且在某些日子里我可以远程更改它。是否有我需要实现的代码,或者是否有可以帮助我的服务?非常感谢各位!
这是目前为止的代码:
#import "ViewController.h"
@interface ViewController ()
@property (strong, nonatomic) IBOutlet UIImageView *imageView;
@end
@implementation ViewController
- (void) viewDidLoad
{
[super viewDidLoad];
//do stuff here
if(&UIApplicationWillEnterForegroundNotification) { //needed to run on older devices, otherwise you'll get EXC_BAD_ACCESS
NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
[notificationCenter addObserver:self selector:@selector(enteredForeground:) name:UIApplicationWillEnterForegroundNotification object:nil];
}
}
- (void)enteredForeground:(NSNotification*) not
{
UIImageView *imageView; // Assumed to already be setup in a view controller
PFQuery *query = [PFQuery queryWithClassName:@"Image"];
[query getObjectInBackgroundWithId:@"nMW24stvhT" block:^(PFObject *imageObject, NSError *error) {
if (!error) {
PFFile *imageFile = imageObject[@"image"];
[imageFile getDataInBackgroundWithBlock:^(NSData *data, NSError *error) {
if (!error && data) {
UIImage *image = [UIImage imageWithData:data];
if (image) {
imageView.image = image;
}
}
}];
}
}];}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
【问题讨论】:
-
这个问题有点宽泛,但基本上您将图像/文件托管在服务器上,您的应用程序会偶尔查找更新的文件。当找到更新的文件时,应用程序会下载该文件并向用户显示新文件。