Clarence
Clarence

Reputation: 1943

identify if there is image on the UIImageview

I am having trouble on identifying if there is an image on the UIImageView.

First of all, i have a static table with uiimageview inside. when user press new page or load the data, they both proceed to the same static table.

But now i want the uiimageview on the new page could show some image placeholder to tell the user can insert pic there. However for the old page with image data, i want to the placeholder to disappear when there is image inside the UIImageView.

How can i do that? I am using the code below to load the data;

- (void)viewDidLoad 
{
   self.set11.image = [UIImage imageWithData:[self.role valueForKey:@"set1"]];
    self.set111.image = [UIImage imageWithData:[self.role valueForKey:@"set1"]];
     self.topview.image = [UIImage imageWithData:[self.role valueForKey:@"toppic"]];}

Upvotes: 0

Views: 118

Answers (3)

Yashesh
Yashesh

Reputation: 1752

Use :

if(imageView.image){
   //image in UIIMageView
}else{
   //No image !!!
}

in your case

self.set11.image = [UIImage imageWithData:[self.role valueForKey:@"set1"]];
if(self.set11.image){
 //image in UIIMageView
}else{
 //No image !!!
}

Upvotes: 3

Nitin Gohel
Nitin Gohel

Reputation: 49730

you can check like this :-

if(yourImageView.image != nil)
{
     //Image in image View
}
else
{

    // image Not Found

}

Upvotes: 1

Saurabh Passolia
Saurabh Passolia

Reputation: 8109

if(self.set11.image)
{
//image is already there
}

Upvotes: 1

Related Questions