Iphone 想在我的应用程序中显示HUD吗
我已经创建了一个应用程序,记录视频并将其存储在服务器上。现在我想在我的应用程序中添加HUD,该HUD将显示,直到我的数据存储在服务器上 我正在使用MKNetworkKit将数据发布到服务器 我试过这个:Iphone 想在我的应用程序中显示HUD吗,iphone,ios,mbprogresshud,Iphone,Ios,Mbprogresshud,我已经创建了一个应用程序,记录视频并将其存储在服务器上。现在我想在我的应用程序中添加HUD,该HUD将显示,直到我的数据存储在服务器上 我正在使用MKNetworkKit将数据发布到服务器 我试过这个: - (void) imagePickerController: (UIImagePickerController *) picker didFinishPickingMediaWithInfo: (NSDictionary *) info { NSString *mediaType
- (void) imagePickerController: (UIImagePickerController *) picker
didFinishPickingMediaWithInfo: (NSDictionary *) info {
NSString *mediaType = [info objectForKey: UIImagePickerControllerMediaType];
//NSLog(@"medea type is: %@ ",mediaType);
if ([mediaType isEqualToString:@"public.movie"]){
// NSLog(@"got a movie");
NSURL *videoURL = [info objectForKey:UIImagePickerControllerMediaURL];
webData = [NSData dataWithContentsOfURL:videoURL];
}
[self dismissModalViewControllerAnimated:NO];
// Handle a movie capture
if (CFStringCompare ((__bridge_retained CFStringRef) mediaType, kUTTypeMovie, 0)
== kCFCompareEqualTo) {
NSString *moviePath = [[info objectForKey:
UIImagePickerControllerMediaURL] path];
if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum (moviePath)) {
UISaveVideoAtPathToSavedPhotosAlbum (moviePath,self, @selector(video:didFinishSavingWithError:contextInfo:), nil);
}
}
self.flUploadEngine = [[fileUploadEngine alloc] initWithHostName:@"reneveledat.net" customHeaderFields:nil];
NSMutableDictionary *postParams = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"testApp", @"appID",
nil];
self.flOperation = [self.flUploadEngine postDataToServer:postParams path:@"/dilipvideotest/savefile.php"];
[self.flOperation addData:webData forKey:@"uploadfile" mimeType:@"video/mov" fileName:@"upload.mov"];
[self.flOperation onCompletion:^(MKNetworkOperation *operation) {
NSLog(@"response string is : %@", [operation responseString]);
response = [operation responseString] ;
[HUD removeFromSuperview];
/*
This is where you handle a successful 200 response
*/
}
onError:^(NSError *error) {
NSLog(@"error : %@", error);
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error"
message:[error localizedDescription]
delegate:nil
cancelButtonTitle:@"Dismiss"
otherButtonTitles:nil];
[alert show];
}];
[self.flUploadEngine enqueueOperation:self.flOperation ];
// for HUD
HUD = [[MBProgressHUD alloc] initWithView:self.view];
HUD.labelText = @"Doing funky stuff...";
HUD.detailsLabelText = @"Just relax";
HUD.mode = MBProgressHUDModeAnnularDeterminate;
[self.view addSubview:HUD];
[HUD showWhileExecuting:@selector(doSomeFunkyStuff) onTarget:self withObject:nil animated:YES];
}
- (void)doSomeFunkyStuff {
float progress = 0.0;
while (progress < 1.0) {
progress += 0.01;
HUD.progress = progress;
usleep(50000);
}
}
在
您正在视图中添加MBProgressHUD 数据上传到服务器后,您需要将其删除 因此,您需要在完成块和错误块中编写删除代码 比如:
好啊继续添加HUD。一旦您尝试并遇到问题,请回到这里,向我们展示您所做的工作,我们将尝试帮助您解决这些问题。我已经添加了它,但我不知道如何添加它,以便它将运行,直到数据存储到服务器,但无论如何,我已经在这里添加了我的代码。那么您有什么具体问题?毫无疑问。请编辑并解释问题所在,我们可以尝试提供帮助。你从发布一个计划到发布一大块代码,却没有关于它如何不适合你的信息。请在问题中添加这些信息,并实际提问。谢谢。事实上我并没有面临这个问题,但我想问的是如何根据我的需要实现我的代码,如果这样做很粗鲁,很抱歉。您已将MBProgress HUD添加到您的视图中,它是否显示???但我仍然使用MBProgressHudModeArderTerminate,它将在数据存储之前全部完成。任何关于在存储数据时使此动画变慢和完成的建议。为此,您需要实现自定义活动指示器,或在中搜索一个
[HUD removeFromSuperview];
[self.flOperation onCompletion:^(MKNetworkOperation *operation) {
NSLog(@"response string is : %@", [operation responseString]);
response = [operation responseString] ;
[HUD removeFromSuperview];
/*
This is where you handle a successful 200 response
*/
}
[self.flOperation onCompletion:^(MKNetworkOperation *operation)
{
[MBProgressHUD hideHUDForView:self.view animated:YES];
NSLog(@"response string is : %@", [operation responseString]);
response = [operation responseString] ;
}
onError:^(NSError *error)
{
[MBProgressHUD hideHUDForView:self.view animated:YES];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:[error localizedDescription] delegate:nil cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];
[alert show];
}];