我目前有异步调用上传照片,照片只是一个base64编码的字符串,并且已经调整大小,所以它不是超大,可能是800x800或类似的东西。
我目前遇到的问题是即使上传工作,用户也无法关闭应用程序,点击主页按钮,或者在应用程序运行时离开应用程序。然而,他们可以在应用程序的其他地方工作,我认为这是一个奖励,但即使他们离开应用程序,我如何继续这个电话?
谢谢!
以下是我所拥有的代码(它的工作原理),(如果他们只是坐在那里就行了)
NSMutableURLRequest *request = [gad.globalObjectManager requestWithObject:nil method:RKRequestMethodPOST path:@"/api/photo/SavePhoto" parameters:paramsSave];
[request setTimeoutInterval:6000];
AFHTTPRequestOperation *operation = [gad.globalClient HTTPRequestOperationWithRequest:request success:^(AFHTTPRequestOperation *operation, id responseObject) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Photo Upload" message:@"Your photo was successfuly uploaded" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Photo Upload" message:@"Your photo took long to upload or the harvest server is down, please try again when you are on a wi-fi connection" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
}];
[gad.globalClient enqueueHTTPRequestOperation:operation];
我使用可变请求的原因是增加超时,我读了其他文章说如果我需要更大的超时我必须直接进入AF Networking,而且由于RESTKit位于顶部我必须这样做
答案 0 :(得分:1)
RestKit网络操作是AFNetworking操作的子类,因此您无论如何都可以访问。
致电setShouldExecuteAsBackgroundTaskWithExpirationHandler:
上的operation
,将其配置为在后台运行。
答案 1 :(得分:0)
所以答案是删除网格,重建网格并再试一次。说真的,这是某种XCode错误,它适用于另一个UI