call super in viewDidUnload.

Only show progress bar if data is not sent all at once.
This commit is contained in:
Jeremy Ellison
2011-01-12 14:51:44 -05:00
parent 38d5b3cbd7
commit 511331ac2a
2 changed files with 13 additions and 7 deletions

View File

@@ -36,6 +36,7 @@
}
- (void)viewDidUnload {
[super viewDidUnload];
[_loadedAtLabel release];
_loadedAtLabel = nil;

View File

@@ -7,28 +7,33 @@
//
#import "UIViewController+RKLoading.h"
#import <Three20/Three20.h>
@implementation UIViewController (RKLoading)
- (void)requestDidStartLoad:(RKRequest*)request {
UIView* overlayView = [self.view viewWithTag:66];
UIView* progressView = [self.view viewWithTag:67];
if (overlayView == nil && progressView == nil) {
overlayView = [[UIView alloc] initWithFrame:self.view.bounds];
if (overlayView == nil) {
overlayView = [[TTActivityLabel alloc] initWithFrame:self.view.bounds style:TTActivityLabelStyleBlackBox text:@"Loading..."];
overlayView.backgroundColor = [UIColor blackColor];
overlayView.alpha = 0.5;
overlayView.tag = 66;
progressView = [[UIProgressView alloc] initWithFrame:CGRectMake(10, 100, 300, 20)];
progressView.tag = 67;
[self.view addSubview:overlayView];
[self.view addSubview:progressView];
}
}
- (void)request:(RKRequest*)request didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite {
UIProgressView* progressView = (UIProgressView*)[self.view viewWithTag:67];
if (progressView == nil) {
if (totalBytesWritten >= totalBytesExpectedToWrite) {
// Uploaded all data at once. don't need a progress bar.
return;
}
progressView = [[UIProgressView alloc] initWithFrame:CGRectMake(10, 100, 300, 20)];
progressView.tag = 67;
[self.view addSubview:progressView];
}
progressView.progress = totalBytesWritten / (float)totalBytesExpectedToWrite;
}