【问题标题】:SKPSMTPMessage and UIProgressViewSKPSMTPMessage 和 UIProgressView
【发布时间】:2011-06-08 04:56:05
【问题描述】:

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

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

感谢您的帮助!

【问题讨论】:

    标签: iphone email background smtp uiprogressview


    【解决方案1】:
    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];
        }
    }
    

    编码愉快!

    【讨论】:

    • 好的..但我的问题是你说“你必须调整这个区域以获得正确的数据”进展“真的非常感谢你;)
    • @Louie:Janky 提到的对我来说也很有趣!我的意思是我知道,大约是邮件的大小,但不知道当前发送了多少(发送电子邮件时,通过班级)!我真的不想编辑 SKPSMTPMessage 类来获取当前的进度状态,但我想,它是唯一的选择,对吧?顺便说一句,你的计时器实际上是一个好点!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-20
    • 1970-01-01
    • 2012-07-23
    • 2020-12-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多