Pages

Showing posts with label external image. Show all posts
Showing posts with label external image. Show all posts

Sunday, January 27, 2013

Create UIView and work with UIImage

First Create UIView by following Coding



UIView *uview = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 600, 600)];
[viewControl addSubview:uview];

Now to load the Image from External source is as follow:

   NSURL * imageURL = [NSURL URLWithString:@"http://ww.url.com/imageName.jpg"];
    NSData * imageData = [NSData dataWithContentsOfURL:imageURL];
    UIImage * image = [UIImage imageWithData:imageData];
    UIImageView *block = [[UIImageView alloc] initWithImage:image];
    block.frame = CGRectMake(10, 10, 200, 200);
    [uview addSubview:block];
    block = nil;
    uview = nil;
    image = nil;
    imageData = nil;
    imageURL = nil;
    

I have used ARC - Automatic Reference counting. So didn't released the variable here.