iOS-“;上载进度视图“;比如新的facebook应用程序

iOS-“;上载进度视图“;比如新的facebook应用程序,ios,xcode,uiview,uiviewcontroller,Ios,Xcode,Uiview,Uiviewcontroller,我想在我的应用程序中有一个“上传进度视图”。就像新的Facebook应用程序一样。“上载视图”仅在上载进度处于活动状态时可见 UIView应该在我应用程序中的每个UIViewController上都可见 我可以在AppDelegate中插入“上载进度视图”吗 我正在使用AFP网络 /莫顿 截图: 正如您所看到的,它是一个带有UIProgressView的simpel UIView。我的问题是如何在每个视图(不同的UIViewController)上显示此进度视图?您是否使用ASIHttpReq

我想在我的应用程序中有一个“上传进度视图”。就像新的Facebook应用程序一样。“上载视图”仅在上载进度处于活动状态时可见

UIView应该在我应用程序中的每个UIViewController上都可见

我可以在AppDelegate中插入“上载进度视图”吗

我正在使用AFP网络

/莫顿

截图:


正如您所看到的,它是一个带有UIProgressView的simpel UIView。我的问题是如何在每个视图(不同的UIViewController)上显示此进度视图?

您是否使用ASIHttpRequest进行上载

如果是,请查看

编辑:

好的,用这个

NSURL *url = [NSURL URLWithString:@"http://api-base-url.com"];
AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:url];
NSData *imageData = UIImageJPEGRepresentation([UIImage imageNamed:@"avatar.jpg"], 0.5);
NSMutableURLRequest *request = [httpClient multipartFormRequestWithMethod:@"POST"   path:@"/upload" parameters:nil constructingBodyWithBlock: ^(id <AFMultipartFormData>formData)     {
[formData appendPartWithFileData:imageData name:@"avatar" fileName:@"avatar.jpg" mimeType:@"image/jpeg"];
}];

AFHTTPRequestOperation *operation = [[[AFHTTPRequestOperation alloc] initWithRequest:request] autorelease];
[operation setUploadProgressBlock:^(NSInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite) {
NSLog(@"Sent %lld of %lld bytes", totalBytesWritten, totalBytesExpectedToWrite);
}];
[operation start];
NSURL*url=[NSURL URLWithString:@”http://api-base-url.com"];
AFHTTPClient*httpClient=[[AFHTTPClient alloc]initWithBaseURL:url];
NSData*imageData=UIImageJPEG表示法([UIImage ImageName:@“avatar.jpg”],0.5);

NSMutableURLRequest*request=[httpClient multipartFormRequestWithMethod:@“POST”路径:@“/upload”参数:nil constructingBodyWithBlock:^(id

是否使用AsitpRequest进行上载

如果是,请查看

编辑:

好的,用这个

NSURL *url = [NSURL URLWithString:@"http://api-base-url.com"];
AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:url];
NSData *imageData = UIImageJPEGRepresentation([UIImage imageNamed:@"avatar.jpg"], 0.5);
NSMutableURLRequest *request = [httpClient multipartFormRequestWithMethod:@"POST"   path:@"/upload" parameters:nil constructingBodyWithBlock: ^(id <AFMultipartFormData>formData)     {
[formData appendPartWithFileData:imageData name:@"avatar" fileName:@"avatar.jpg" mimeType:@"image/jpeg"];
}];

AFHTTPRequestOperation *operation = [[[AFHTTPRequestOperation alloc] initWithRequest:request] autorelease];
[operation setUploadProgressBlock:^(NSInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite) {
NSLog(@"Sent %lld of %lld bytes", totalBytesWritten, totalBytesExpectedToWrite);
}];
[operation start];
NSURL*url=[NSURL URLWithString:@”http://api-base-url.com"];
AFHTTPClient*httpClient=[[AFHTTPClient alloc]initWithBaseURL:url];
NSData*imageData=UIImageJPEG表示法([UIImage ImageName:@“avatar.jpg”],0.5);

NSMutableURLRequest*request=[httpClient multipartFormRequestWithMethod:@“POST”路径:@“/upload”参数:nil constructingBodyWithBlock:^(id

这可以做同样的行为。

这可以做同样的行为。

请发布一个屏幕截图,不是所有人都使用Facebook:)请发布一个屏幕截图,不是所有人都使用Facebook:)很酷…谢谢。但我的问题更多的是如何在每个屏幕上显示带有AFNetworking uploadProgress数据的UIProgressView(UIViewController)我的应用程序中有。我希望用户看到上传进度有多远,无论哪个ViewController处于活动状态。-但感谢您的快速回复:)也许如果您在AppDelegate中定义UIView,在每个视图中调用它并附加它,它有一个ViewController的子视图,它将工作。酷…谢谢。但我的问题更多的是如何显示UIView进度在每个屏幕上查看AFNetworking uploadProgress的数据(UIViewController)我的应用程序中有。我希望用户查看上传进度有多远,无论哪个ViewController处于活动状态。-但感谢您的快速回复:)如果您在AppDelegate中定义UIView,请在每个视图中调用它,并将其附加到ViewController的子视图中,它将正常工作。