0

我正在使用这个库 (http://code.google.com/p/skpsmtpmessage/) 在我的 iPhone 应用程序中发送电子邮件

在发送过程中如何实现 UIProgressView?

谢谢你的帮助!

4

1 回答 1

0
  1. 1.在你的 .h 中创建你的 UIProgressView 以及一个 BOOL 和 NSTimer 以及一个名为 updateProgress 的函数

    2.在你的.m文件中合成

    3.在您的“viewDidLoad”中将 BOOL 的初始值设置为 NO ,并创建一个计时器

您的 .h 文件应包括

UIProgressView * progressView;
BOOL emailSent;
NSTimer * timer;

-(void)updateProgress;
@property(nonatomic, retain)UIProgressView * progressView;
@property(nonatomic, assign)BOOL emailSent;
@property(nonatomic, retain)NSTimer * timer;

您的 .m 文件应包括

@synthesize progressView, emailSent,timer;

//viewdidload
//set initial value to no
emailSent = NO;

//since we cant interact with UIElements on anything but the Main thread we use a timer
//because you are probably sending the email in a seperate thread
timer= [NSTimer scheduledTimerWithTimeInterval:.1 target:self selector:@selector(updateProgress) userInfo:nil repeats:YES];

//create this function
-(void)updateProgress{


    //wait for email to be done
    if (emailSent == NO) {

// you'll have to tweak this area to get the correct data "progress"    
float fullValue = .0032;
int progressInt = (app.parsedCount * z);

//progressInt is the representation of how much data has been completed.
        progressView.progress = progressInt;
    }
    else {

    //email is done 
    emailSent = YES;

        //kill the timer so it doesnt continue to run
    [timer invalidate];
    //email sent so you can remove your progress view
         [self.view removeSubView:progressView];
    }
}

快乐编码!

于 2011-06-07T20:56:05.720 回答