【发布时间】:2011-07-28 22:16:40
【问题描述】:
我正在做一个同步网络请求,我想显示进度,但更重要的是,一旦我点击“开始”,它就会开始比赛,忽略诸如打开 NetworkActivty 微调器或更改标签之类的事情.
我意识到进度条可能必须等到我有时间异步编写提取,但是我可以让程序等到标签改变吗?或者至少是一种伪造的方法?
在我拥有的 UIButton 上的 TouchUpInside 上。 . .
-(IBAction)startButtonPressed
{ [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
NSString *lastUpdate = [[self getLastUpdateDate] stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
startButton.enabled = NO;
cancelButton.enabled = NO;
resetSwitch.enabled = NO;
cleanSwitch.enabled = NO;
//check the # of customer updates and update accordingly
statusLabel.text = @"Updating Customers. . .";
//[self performSelector:(@selector(updateProgress:withStatus:)) withObject:0.0f withObject:@"Updating Customers. . . " afterDelay:500];
//[self performSelector:(@selector(updateProgressIndicators)) withObject:nil afterDelay:0];
if (clean) {
[self deleteALL];
}
if ([self customersCount] < 1000 && !reset)
[self addCustomers:lastUpdate];
else
[self addCustomers:nil];
//check the # of product updates and update accordingly, reset does not affect products
statusLabel.text = @"Updating Products. . .";
if ([self productsCount] < 25000 || !clean)
[self addProducts:lastUpdate];
else
[self addProducts:nil];
//check the # of vendor updates and update accordingly, reset does not affect vendors
statusLabel.text = @"Updating Vendors. . . ";
if ([self vendorsCount] < 1000 || !clean || [[self fetchVendor:@"0002"] count] == 0) {
[self addVendors:lastUpdate];
}else{
[self addVendors:nil];
}
statusLabel.text = @"Updating History. . . ";
[self getHistory];
statusLabel.text = @"Updating Custom Pricing. . . ";
if ([self customPricesCount] < 500 && !reset) {
[self addCustomPrices:lastUpdate];
}else{
[self addCustomPrices:nil];
}
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"MM-dd-yyyy HH:mm:ss"];
[self setLastUpdateDate:[dateFormatter stringFromDate:[NSDate date]]];
[dateFormatter release];
statusLabel.text = @"Done!";
cancelButton.enabled = YES;
cancelButton.tag = 1;
cancelButton.titleLabel.text = @"Close";
startButton.enabled = NO;
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
}
【问题讨论】:
标签: ios xcode ipad asihttprequest