Tag: 可用视图

当tableview滚动时计数值被改变

这是我的CellForRowAtIndexPath代码 – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath; { static NSString *simpleTableIdentifier = @"PickAClassCell"; cell = (PickAClassCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier]; if (cell == nil) { NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"PickAClassCell" owner:self options:nil]; cell = [nib objectAtIndex:0]; } cell.CountLabel.tag=1000; [cell.PlusCount addTarget:self action:@selector(PlusButtonSelect :)forControlEvents:UIControlEventTouchUpInside]; return cell; } -(void)PlusButtonSelect :(UIButton *)sender { UILabel *label1 = (UILabel *)[sender.superview viewWithTag:1000]; NSLog(@"%@",label1); […]

UiTableView标题不会消失

我有一个UITableViewconfiguration为普通样式,所以我可以将表头视图停留在表的顶部,直到另一个标题将其拉下。 问题是:如果我有一个标题卡在屏幕的顶部,并以编程方式滚动到表的另一部分(该标题不应该出现在那里),该UIView将不会被解雇。 也就是说,如果我再次滚动到表格的那一部分,那么这个表头的一个鬼影将在表格的那个部分上可见。 我已经实现了方法- (void)tableView:(UITableView *)tableView didEndDisplayingHeaderView:(nonnull UIView *)view forSection:(NSInteger)section来理解发生了什么。 我发现,如果我手动滚动,直到一个标题拉离屏幕,这个委托被调用。 但是,如果我以编程方式滚动,代理不会被调用。 顺便说一句,我试着用两种不同的方法编程滚动,问题是一样的。 – (void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated; – (void)scrollToRowAtIndexPath:(NSIndexPath *)indexPath atScrollPosition:(UITableViewScrollPosition)scrollPosition animated:(BOOL)animated; 我可以想象的一个解决方法是实现- (void)scrollViewDidScroll:(UIScrollView *)scrollView; ,筛选可见屏幕之外的所有标题视图,并从超级视图中删除它们。 我可以让它工作,但我想知道是否还有其他更好的解决scheme。 [编辑]如果我调用- (void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated; 与animation= YES,错误不会发生。 我可以去这个解决scheme,但我真的希望在一些情况下滚动没有animation。

表视图麻烦与出列单元格

所以我无法在UITableView显示数据。 我相信这与重用单元格有关。 我已经在网上查询,但没有find适合我的解决scheme。 任何帮助,将不胜感激。 我有一个由文本和图片填充的数组。 我然后在tableView显示信息。 如果我使用静态大小的单元格,一切正常,但文本的数量发生了变化,所以我也实现了heightForRowAtIndexPath方法。 这也适用,直到我滚动到底部。 之后,当我向上滚动时,所有的单元格高度都会改变,显示将全部混乱。 一些文本被截断,图片被切碎,一些单元格只有文本的最后部分。 我真的认为这与重用单元格有关,但我不知道如何解决这个问题。 以下是我的代码cellForRowAtIndexPath和heightForRowAtIndexPath 。 – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; } if ([[_theBigArray objectAtIndex:indexPath.row] isKindOfClass:[NSString class]]) { NSString *label = [_theBigArray objectAtIndex:indexPath.row]; CGSize […]

在UITableView-XMLparsing中混合了图像

编辑:其实图像显示正常,这是当我滚动,他们混在一起… 我正在parsing一个XML文件,并将其链接到我正在放入UITable的图像中。 出于某种原因,图片变得混乱起来,当我向下滚动桌子时,他们中的一些甚至开始改变! 这里是我用于我的UITable的代码: – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; Tweet *currentTweet = [[xmlParser tweets] objectAtIndex:indexPath.row]; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]; CGRect imageFrame = CGRectMake(2, 8, 40, 40); customImage = [[UIImageView alloc] initWithFrame:imageFrame]; [cell.contentView addSubview:customImage]; } NSString *picURL […]

在Firebase中填充UITableView一次设置单元格数量

我正在使用Firebase来填充UITableView 。 我想知道是否有可能让Firebase下载前5个结果,并且一旦用户滚动到最后的结果,就下载下5个结果。 目前,Firebase一次下载我的所有子节点,但是如果它一点一点地执行,则视图将加载得更快。 有什么build议? – 编辑 注意到单元格中有图像是很重要的。 图像是base64编码的NSString s。 这里是我用来检索它们并将它们转换成UIImage的代码 NSString* profPicString = [child.value objectForKey: @"profilePicture"]; NSData *dataFromBase64 = [NSData base64DataFromString:profPicString]; UIImage *profPicImage = [[UIImage alloc]initWithData:dataFromBase64]; item.profilePicture = profPicImage;

有可能在一个xib中创build多个单元格吗?

我发现它可以用不同的xib创build不同的单元格,但是我想知道是否可以在一个xib中创build不同的单元格? 如果可能,我该怎么做? 这里是代码,我知道这是错误的代码,所以你们可以帮我解决它吗? – (void)viewDidLoad { [super viewDidLoad]; [imageTableView registerNib:[UINib nibWithNibName:@"ImageTableViewCell" bundle:nil] forCellReuseIdentifier:@"oneImageTableViewCell"]; [imageTableView registerNib:[UINib nibWithNibName:@"ImageTableViewCell" bundle:nil] forCellReuseIdentifier:@"twoImageTableViewCell"]; } – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ NSString *identifier1 = @"oneImageTableViewCell"; NSString *identifier2 = @"twoImageTableViewCell"; if (indexPath.row % 2 == 0) { ImageTableViewCell *cell = [imageTableView dequeueReusableCellWithIdentifier:identifier1 forIndexPath:indexPath]; return cell; } else { ImageTableViewCell *cell = [imageTableView […]

如何使用commitEditingStyle从plist删除数组?

我有一个UITableView由plist的数组键通过此代码填充: -(void)viewWillAppear:(BOOL)animated { // get paths from root direcory NSArray *paths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES); // get documents path NSString *documentsPath = [paths objectAtIndex:0]; // get the path to our Data/plist file NSString *plistPath = [documentsPath stringByAppendingPathComponent:@"Data.plist"]; NSMutableDictionary *dictionary = [NSMutableDictionary dictionaryWithContentsOfFile:(NSString *)plistPath]; viewerKeys = [dictionary allKeys]; [self.tableView reloadData]; } – (UITableViewCell *)tableView:(UITableView *)tableView […]

滚动时,UITableView单元格变空白

我已经在UITableViewController中设置了单个部分,单个单元格自定义单元格来显示比屏幕更长的视图。 但是在testing时,我注意到在离开视图区域之前向下滚动时单元格会消失(空白)。 这不是什么幻想,但我不明白为什么滚动下来会消失,尤其是当它远离可视区域时。 – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { VendorDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:@"VendorDetailCell"]; cell.vendorImage.image = [UIImage imageWithData: self.imageData.data]; cell.vendorTitle.text = self.imageData.vendorTitle; cell.vendorDescription.text = self.imageData.vendorDescription; return cell; }

search视图总是显示在桌面上

我拿了一个UITableViewController,并试图在其中添加UISearchDisplayController。 我从互联网阅读了很多代码,但不知道我的错在哪里。 我的问题是为什么UISearchDisplayController不要总是坚持在UITableView之上。 这是我的代码 SearchView_controller.h @interface SearchView_controller : UITableViewController<UISearchBarDelegate,UISearchDisplayDelegate> @end SearchView_controller.m @interface SearchView_controller () { UISearchDisplayController *searchController; } @end @implementation SearchView_controller – (void)viewDidLoad { [super viewDidLoad]; self.title=@"Test"; UISearchBar *searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, self.tableView.frame.origin.y, self.tableView.frame.size.width, 44)]; [searchBar sizeToFit]; [searchBar setDelegate:self]; searchController = [[UISearchDisplayController alloc] initWithSearchBar:searchBar contentsController:self]; [searchController setSearchResultsDataSource:self]; [searchController setSearchResultsDelegate:self]; [searchController setDelegate:self]; [self.tableView setTableHeaderView:searchController.searchBar]; } […]

UITableView重复Firebase数据

我正在从Firebase获取重复的内容,而我似乎无法弄清楚我做错了什么。 在firebase我有6个职位。 tableview是填充6个单元格,但所有6个单元格具有相同的数据,其他5个职位不在那里。 – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { RankingsCell *cell = [tableView dequeueReusableCellWithIdentifier:@"RankingsCell"]; self.ref = [[FIRDatabase database] reference]; posts = [ref child:@"posts"]; [posts observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) { for (snapshot in snapshot.children) { NSString *username = snapshot.value[@"Name"]; NSString *date = snapshot.value[@"Date"]; NSString *combatPower = snapshot.value[@"Combat Power"]; NSString *pokemon = snapshot.value[@"Pokemon"]; NSString *pokemonURL = snapshot.value[@"Pokemon […]