iosobjective-ccgsize

value of type CGSize is not contextually convertible to bool


I'm calculating the image value of height and width and checking with if condition whether the imagsize is available or not. If not then i'm assigning some value to UIImageView size. But when i check the imagesize in if condition i got this error value of type CGSize is not contextually convertible to bool

CGSize imageSize = CGSizeMake(350 * widthRatio, height);

      if(imageSize){

            mmageView=[[UIImageView alloc]init];

            CGRect frame = mmageView.frame; frame.size = imageSize; mmageView.frame = frame;

        }else{

              mmageView=[[UIImageView alloc]initWithFrame:CGRectMake(50,50,150,150)];


        }

Solution

  • as your code check this way

    if(imageSize.height != 0 && imageSize.width != 0){
    
       mmageView=[[UIImageView alloc]init];
    
       CGRect frame = mmageView.frame; frame.size = imageSize; mmageView.frame = frame;
    
    }else{
         mmageView=[[UIImageView alloc]initWithFrame:CGRectMake(50,50,150,150)];
    }