UITableView不显示IOS 7中的单元格

UITableView不显示IOS 7中的单元格,第1张

概述当我尝试将我的应用程序从iOS6转换为iOS7 / iOS8时,我遇到了这个问题. UITableView不显示单元格(在iOS6中工作). 我有一个类似的视图,在iOS7中工作正常(它没有UISearchView) 我尝试了几种解决方法,比如清除背景,删除UISearchBar等等…… 两个示例中的代码类似(单元格由 – (UITableViewCell *)tableView生成:(UITab 当我尝试将我的应用程序从iOS6转换为iOS7 / iOS8时,我遇到了这个问题.

UItableVIEw不显示单元格(在iOS6中工作).

我有一个类似的视图,在iOS7中工作正常(它没有UISearchVIEw)

我尝试了几种解决方法,比如清除背景,删除UISearchbar等等……

两个示例中的代码类似(单元格由 – (UItableVIEwCell *)tableVIEw生成:(UItableVIEw *)tableVIEw cellForRowAtIndexPath:(NSIndexPath *)indexPathmethod)

我使用Reveal软件来分析这个层次结构.

在XCODE 4中为iOS6支持编译的代码工作正常. (使用iOS7在iphone 5s上测试)

编辑:

- (UItableVIEwCell *)tableVIEw:(UItableVIEw *)tableVIEw cellForRowAtIndexPath:(NSIndexPath   *)indexPath{static Nsstring *CellIDentifIEr = @"CellAloj";AlojamentotableCell *cell = [tableVIEw dequeueReusableCellWithIDentifIEr:CellIDentifIEr forIndexPath:indexPath];if(cell==nil){    posicao=0;}posicao=70+(100*indexPath.row);[bdAl.arrayFotos removeAllObjects];    NSMutableString *simbpreco=[[NSMutableString alloc]init];NSNumber *ID1=[bdAl.IDAlojamento objectAtIndex:indexPath.row];[self drawvIEwRank:[ID1 integerValue]];//posicao=posicao+100;cell.backgroundVIEw=[[UIImageVIEw alloc]initWithImage:[UIImage imagenamed:@"aloj_cell3.png"]];//Não aparecer mais celulas depois da última com conteúdoUIVIEw *footer = [[UIVIEw alloc] initWithFrame:CGRectZero];self.tableVIEw1.tableFooterVIEw = footer;///////////////[bdAl SelectFotos:[[bdAl.IDAlojamento objectAtIndex:indexPath.row]integerValue]];cell.nomeAloj.text=[bdAl.arrayNomeAloj objectAtIndex:indexPath.row];cell.imgaloj.image=[[UIImage alloc]init];UIImage *imagem=[bdAl.arrayFotos objectAtIndex:0];cell.tipo.text=[bdAl.arrayTipoAloj objectAtIndex:indexPath.row];cell.labelLocalIDade.text=[bdAl.arrayLocalIDade objectAtIndex:indexPath.row];cell.imgaloj.image=imagem;CALayer * l = [cell.imgaloj layer];[l setMasksToBounds:YES];[l setCornerRadius:10.0];cell.detailAloj.text=[bdAl.arrayDescAloj objectAtIndex:indexPath.row];int i=[[bdAl.arraypreco objectAtIndex:indexPath.row]integerValue];for (int j=0; j<i; j++){    [simbpreco appendString:@"€"];}[tableVIEw1 setSeparatorStyle:UItableVIEwCellSeparatorStyleSingleline];[tableVIEw1 setSeparatorcolor:[UIcolor colorWithPatternImage:[UIImage imagenamed:@"nav_menu.png"]]];cell.preco.text=simbpreco;return cell;

EDIT2:

故事板:

EDIT3:此方法返回17行:

- (NSInteger)tableVIEw:(UItableVIEw *)tableVIEw numberOfRowsInSection:(NSInteger)section{    return [bdAl.arrayNomeAloj count];}

和numberOfSectionsIntableVIEw方法:

- (NSInteger)numberOfSectionsIntableVIEw:(UItableVIEw *)tableVIEw{    return 1;}

EDIT4:

#import <UIKit/UIKit.h>#import "AlojamentotableVIEwController.h"@interface AlojamentotableCell : UItableVIEwCell{}@property (strong,nonatomic) IBOutlet UILabel *tipo;@property (strong,nonatomic)IBOutlet UILabel *nomeAloj;@property (strong,nonatomic)IBOutlet UILabel *detailAloj;@property (strong,nonatomic)IBOutlet UIImageVIEw *imgaloj;@property (strong,nonatomic) IBOutlet UILabel *labelLocalIDade;@property (strong,nonatomic)IBOutlet UILabel *preco;@end
解决方法 我弄明白了这个问题:

我有这个方法:

-(voID)RemoveAllObjects{    [bdAl.arrayLocalIDade removeAllObjects];    [bdAl.IDAlojamento removeAllObjects];    [bdAl.arrayDescAloj removeAllObjects];    [bdAl.arrayFotos removeAllObjects];    [bdAl.arrayMail removeAllObjects];    [bdAl.arrayTipoAloj removeAllObjects];    [bdAl.arrayMorAloj removeAllObjects];    [bdAl.arrayNomeAloj removeAllObjects];    [bdAl.arrayStar removeAllObjects];    [bdAl.arrayTelf removeAllObjects];    [bdAl.arraypreco removeAllObjects];    NSArray *subvIEws = [self.tableVIEw1 subvIEws];    for (int i=0; i<[subvIEws count]; i++)    {       [[subvIEws objectAtIndex:i] removeFromSupervIEw];    }    //posicao=90;}

在用户开始使用搜索功能时清除所有内容.在VIEwWillAppear中调用此方法.

我删除它,一切正常.

谢谢大家(我知道,我必须检查所有代码.)

编辑:UISerachVIEw层次结构在iOS7中发生了变化,这就是子视图计数失败的原因.

总结

以上是内存溢出为你收集整理的UITableView不显示IOS 7中的单元格全部内容,希望文章能够帮你解决UITableView不显示IOS 7中的单元格所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1060803.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-25
下一篇2022-05-25

发表评论

登录后才能评论

评论列表(0条)

    保存