Iphone SKPSMTPMessage和UIProgressView

Iphone SKPSMTPMessage和UIProgressView,iphone,email,background,smtp,uiprogressview,Iphone,Email,Background,Smtp,Uiprogressview,我正在使用这个图书馆http://code.google.com/p/skpsmtpmessage/ 在我的iPhone应用程序中发送电子邮件 如何在发送过程中实现UIProgressView 谢谢你的帮助 1.在.h中创建UIProgressView以及BOOL和NSTimer,并 一个名为updateProgress的函数 2.在.m文件中进行合成 3.在viewDidLoad中,将BOOL的初始值设置为NO,并创建一个 计时器 您的.h文件应该包括 UIProgressView * pro

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

如何在发送过程中实现UIProgressView

谢谢你的帮助

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;
@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];
    }
}
你的.m文件应该包括

UIProgressView * progressView;
BOOL emailSent;
NSTimer * timer;

-(void)updateProgress;
@property(nonatomic, retain)UIProgressView * progressView;
@property(nonatomic, assign)BOOL emailSent;
@property(nonatomic, retain)NSTimer * timer;
@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];
    }
}

快乐编码

好的。。但我的问题是,你说你必须调整这个区域以获得正确的数据进度,非常感谢你@路易:詹基提到的对我来说也很有趣!我的意思是,我知道,大概是邮件的大小,但不知道在通过课堂发送电子邮件时当前发送了多少!我真的不想编辑SKPSMTPMessage类来获取当前进度状态的信息,但我想,这是唯一的选择,对吗?顺便说一句,有了计时器,这实际上是一个很好的观点!