Hello,
I have a application, and had to create another .h and .m file. This is so my downloads will be down in the background
.h File
#import <UIKit/UIKit.h>
@interface AsynchronousImageView : UIImageView
{
NSURLConnection *connection;
NSMutableData *data;
}
- (void)loadImageFromURLString:(NSString *)theUrlString;
@end
And .m file
#import "AsynchronousImageView.h"
#import "DxxxAppDelegate.h"
@implementation AsynchronousImageView
- (void)loadImageFromURLString:(NSString *)theUrlString
{
[self.image release], self.image = nil;
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:theUrlString]
cachePolicy:NSURLRequestReturnCacheDataElseLoad
timeoutInterval:30.0];
connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
}
- (void)connection:(NSURLConnection *)theConnection
didReceiveData:(NSData *)incrementalData
{
if (data == nil)
data = [[NSMutableData alloc] initWithCapacity:2048];
[data appendData:incrementalData];
}
- (void)connectionDidFinishLoading:(NSURLConnection *)theConnection
{
self.image = [UIImage imageWithData:data];
[data release], data = nil;
[connection release], connection = nil;
}
- (void)dealloc {
[data release];
[connection release];
[super dealloc];
}
@end
Basicilly, i imported my .h file for my main xxx.appdelege so i could access a few of the Navigation COntrollers so i can push views.
Im basiclly trying to, download a picture, then once its completed display a view(loading view) when the download starts and remove view(loading screen) and push the main view with the UIImage.view is held.
I found these files online, they work but i cant find how i can do this. Any options?
Im trying to make it so, once it starts, i push a view using for loading, then i unload that screen and push the below
[navigationController pushViewController:vFullscreen animated:YES];
Can someone assist me? I went down this path because NSThread locked up because i tried to access UI things.
Thanks