如何使用iPhone应用程序中的进度条 [英] how to use the progress bar in the iphone app

查看:176
本文介绍了如何使用iPhone应用程序中的进度条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的iPhone应用程序中,我从FTP服务器下载一些数据。显示我正在使用的操作 UIActivityIndi​​cator 。如果我把 UIProgressView 放在那里而不是 UIActivityIndi​​cator ,那将更合适。下载某些数据时如何使用 UIProgressView ?任何人都可以给我一个教程链接或示例代码吗?在此先感谢。

In my iPhone app I am downloading some data from an FTP server. To show the action I am using UIActivityIndicator. If I put UIProgressView there instead of UIActivityIndicator, it will be more appropriate. How do I use UIProgressView while downloading some data? Can anybody give me a tutorial link or example code? Thanks in advance.

推荐答案

首先在.h文件中创建IBOutlet

first you create IBOutlet in .h file

IBOutlet UIProgressView * threadProgressView;

然后在viewdidload中的.m文件中首先将进度设置为0.0,然后调用makeMyProgressMoving方法

Then in .m file in viewdidload first set progress to 0.0 and then call makeMyProgressMoving method

    threadProgressView.progress = 0.0;
    [self performSelectorOnMainThread:@selector(makeMyProgressBarMoving) withObject:nil waitUntilDone:NO];

然后添加以下方法

- (void)makeMyProgressBarMoving {

        float actual = [threadProgressView progress];
        if (actual < 1) {
            threadProgressView.progress = actual + ((float)recievedData/(float)xpectedTotalSize);
            [NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(makeMyProgressBarMoving) userInfo:nil repeats:NO];
        }
        else{



        }

    } 

还提供您的回答评论。对你有用吗?

also give your review for answer. is it useful to you?

这篇关于如何使用iPhone应用程序中的进度条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆