【问题标题】:Hide a UIImageview in UITableView Custom cell在 UITableView 自定义单元格中隐藏 UIImageview
【发布时间】:2013-09-07 05:32:31
【问题描述】:

如果设备是iOS 6.0 + 版本,我试图在UITableView 单元格中隐藏UIImageView。如果设备使用iOS 6.0 或更低版本,我想显示UIImageView

下面的代码对我不起作用。我可以在两个版本中看到 UIImage

- (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;
}

【问题讨论】:

  • 您是否尝试调试并确保 rupeeSymbol 具有价值?有时我们确实忘记将插座与笔尖连接起来。
  • 你在哪个版本测试它?
  • 试试if([[[UIDevice currentDevice]systemVersion] floatValue]&lt;6.0f){ }
  • 感谢您的 cmets 现在正在工作

标签: ios objective-c uitableview uiimageview


【解决方案1】:

添加以下代码

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

到您的 projectName-Perfix.pch 文件,以便您可以从项目中的任何位置访问它。

上面的代码不需要做额外的重复工作。

并且只需放置诸如 (项目中的任何位置)之类的条件

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

【讨论】:

    猜你喜欢
    • 2020-02-29
    • 2014-12-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多