English 中文(简体)
如何增加iPhone 的进度视图, 直至服务器以 JSON 的形式回应 。
原标题:How to increase progress view in iPhone, till the response coming from server in the form of JSON
  • 时间:2012-05-21 07:31:12
  •  标签:
  • iphone

我在iPhone开发中是新来的, 想要在我的应用程序中添加进度视图, 有人能帮助我如何在我的 iPhone 应用程序中添加进度视图,

问题回答

这是使用 mbprogessshud 的样本代码, 希望 u 也可以用此方法设置您进度视图的进展 。 请参考 nsurldlegate 方法, 它们是如何根据服务器上的数据来设定进度的 。

  - (IBAction)showWIthLabelAnnularDeterminate:(id)sender {
        HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view];
        [self.navigationController.view addSubview:HUD];

        // Set determinate mode
        HUD.mode = MBProgressHUDModeAnnularDeterminate;

        HUD.delegate = self;
        HUD.labelText = @"Loading";

        // myProgressTask uses the HUD instance to update progress
        [HUD showWhileExecuting:@selector(myProgressTask) onTarget:self withObject:nil animated:YES];
    }



    #pragma mark -
    #pragma mark NSURLConnectionDelegete

    - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
        expectedLength = [response expectedContentLength];
        currentLength = 0;
        HUD.mode = MBProgressHUDModeDeterminate;
    }

    - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
        currentLength += [data length];
        HUD.progress = currentLength / (float)expectedLength;
    }

    - (void)connectionDidFinishLoading:(NSURLConnection *)connection {
        HUD.customView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"37x-Checkmark.png"]] autorelease];
        HUD.mode = MBProgressHUDModeCustomView;
        [HUD hide:YES afterDelay:2];
    }

    - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
        [HUD hide:YES];
    }




相关问题
Code sign Error

I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

• 如何将搜查线重新定位?

我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。

热门标签