If no Table View results, display “No Results” on screen

后端 未结 14 1613
挽巷
挽巷 2020-11-30 17:25

I have a tableview, where sometimes there might not be any results to list, so I would like to put something up that says \"no results\" if the

14条回答
  •  独厮守ぢ
    2020-11-30 17:49

    Use this code in Your numberOfSectionsInTableView method:-

    if ([array count]==0
    {
    
        UILabel *fromLabel = [[UILabel alloc]initWithFrame:CGRectMake(50, self.view.frame.size.height/2, 300, 60)];                                                                                        
        fromLabel.text =@"No Result";
        fromLabel.baselineAdjustment = UIBaselineAdjustmentAlignBaselines;
        fromLabel.backgroundColor = [UIColor clearColor];
        fromLabel.textColor = [UIColor lightGrayColor];
        fromLabel.textAlignment = NSTextAlignmentLeft;
        [fromLabel setFont:[UIFont fontWithName:Embrima size:30.0f]];
        [self.view addSubview:fromLabel];
        [self.tblView setHidden:YES];
    }
    

提交回复
热议问题