如何使用json隐藏Empty UITableViewcell Label?

时间:2014-06-13 12:44:48

标签: json uitableview

嗨我需要在自定义TableView.i中隐藏空的UITableViewcell标签我试图在自定义tableviewcell中显示JSON webservice值。    我的json vales看起来像......

  (
    {
    post =         {
    "CLASS_LEVEL" = "Intro/General";
    "CLASS_TYPE" = "Muay Thai";
    "DAY_OF_WEEK" = "";
    ID = 19;
   "ORDER_BY" = 5;
   TIME = "1:00pm - 2:30pm";
    };
 }
   {
    post =         {
    "CLASS_LEVEL" = "General/Intermediate/Advanced";
    "CLASS_TYPE" = "Muay Thai Spar - Competitive";
     "DAY_OF_WEEK" = "";
     ID = "";
    "ORDER_BY" = 5;
    TIME = "6:00pm - 9:00pm";
    };
   },

   {
     post =         {
    "CLASS_LEVEL" = "Fighters/Advanced/Intermediate";
    "CLASS_TYPE" = "Fighters Training";
    "DAY_OF_WEEK" = Monday;
    ID = 1;
    "ORDER_BY" = 1;
    TIME = "";
    };
    },

我需要动态自动调整表格单元格大小。

这里的一些值是空的,tableviewcell中指定标签的值想要隐藏。

有可能吗?帮助我。谢谢你提前

2 个答案:

答案 0 :(得分:0)

要隐藏UILabel,您只需cell.label.hidden = YES;

即可

答案 1 :(得分:0)

你可以试试这个

NSString *dayOfWeek = ... ;

if(dayOfWeek == (id) [NSNull null] || [dayOfWeek length] == 0 || [dayOfWeek isEqualToString:@""])
{
    cell.label.hidden = YES;
}
else
{
    cell.label.hidden = NO;
}