简体   繁体   中英

Hide a UIImageview in UITableView Custom cell

Iam trying to hide a UIImageView in UITableView cell ,if the device is in iOS 6.0 + version. and i wanna show the UIImageView if the device using iOS 6.0 or lower version ?

Below code is not working for me.I can see the UIImage in both versions.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    //NSLog(@"%@",recentBookName);
    static NSString *CellIdentifier = @"Cell";
    GMMListViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    cell.NameLabel.text=[BookName objectAtIndex:indexPath.row];
    cell.authorLabel.text=[AuthorName objectAtIndex:indexPath.row];

    if([[[UIDevice currentDevice]systemVersion] floatValue]<6.0){
        cell.rupeeSymbol.hidden=NO;

    }else{
     cell.rupeeSymbol.hidden=YES;

    }

return cell;
}

Add following code

#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)

To your projectName-Perfix.pch file so you can access it from anywhere in your project.

This above code is for no need to do extra repeat work.

And just put condition such like (Anywhere in your project)

if(SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"6") )
{
   // do your stuff for iOS >= 6 
}
els
{
  // do your stuff for iOS <= 6
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM