how to use the progress bar in the iphone app

后端 未结 5 1918
情歌与酒
情歌与酒 2020-12-07 21:31

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 in

5条回答
  •  情深已故
    2020-12-07 21:50

    first you create IBOutlet in .h file

    IBOutlet UIProgressView * threadProgressView;
    

    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];
    

    then add below method

    - (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?

提交回复
热议问题