Saturday, March 3, 2012

Grab the image Data from web or mainBundle

-(void) grabImagefromURL
{
    NSURL *url = [NSURL URLWithString:@"http://cultofmac.cultofmaccom.netdna-cdn.com/wp-content/uploads/2010/01/apple-vs-google_2.jpg"];
    imageData = [NSData dataWithContentsOfURL:url];
    UIImage *image  = [[UIImage alloc] initWithData:imageData];
    myImageView.image = image;
    [image release];
    
}

- (void) grabImagefromFile
{

    NSString *filePath = [[NSBundle mainBundle] pathForResource:@"lion" ofType:@"jpg"]; 

    UIImage *image = [UIImage imageWithContentsOfFile:filePath];
    UIImageView *imageView = [[UIImageView alloc] initWithImage:img];
    [self.view addSubview:imageView];

No comments:

Post a Comment