Tag: uitableview

在第四行更改内容时,uitableview单元格更改第一行中的内容

我有一个特定单元格的手势桌面视图。 在tableview加载后,我滚动到第四行,并向左滑动显示一些内容,其工作正常。 但之后,当我回到第一行,它也显示在第四行相同的内容。 当我运行这个代码与ios8,其工作正常。以上问题只发生在我运行这个在ios7中。 我的代码如下: – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { SampleViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"]; if(cell == nil) { cell = [[SampleViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"]; } NSMutableDictionary *cellData = [self.databaseCall transactionFromDatabase:indexPath.row Id:self.Id andStageId:self.stageId]; [self setSelectedSegmentColor:cell.repeat]; cell.Description.text = self.Name; cell.actionDescription.text = self.Name; cell.tipsDescription.text = [cellData objectForKey:@"tipsDescription"]; UIImage *cellImage = [UIImage imageNamed:[cellData objectForKey:@"categoryImage"]]; NSLog(@"%@", [cellData […]

在已经出现的时候改变dynamic高度UITableViewCell的高度

我按照这个教程创build了一个dynamic高度的UITableViewCell。 我的原型单元格有一个标签(非常简单)。 对于单元边的所有边,该标签都将约束设置为“0”。 该标签有numberOfLines = 0并包装单词。 在我的UITableView设置中,我这样做: self.tableView.rowHeight = UITableViewAutomaticDimension self.tableView.estimatedRowHeight = 100.0 //some random number 基本上,一切正常。 每个单元有不同的高度。 当我用不同的文本更新标签时,问题就出现了。 单元格的高度保持不变,文本被截断或出现空白。 有没有办法告诉细胞“重绘”自己,以便再次计算高度? 理想情况下,我想在UITableViewCell类中做这个,因为这是接收通知来更新标签文本的地方。

内联UIPicker实现

我试图在表视图单元内实现一个内联的UIPicker,类似于这个和这个 SO问题。 我相信我在实施中很接近,但是现在,当我select合适的单元格时,不会显示select器。 任何人都可以指出我在正确的方向,我做错了什么? 谢谢! 以下是我确定每个部分中发生的行的位置: – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { switch (indexPath.section) { case NotificationsSection: return [self tableView:tableView cellForAreaOneRowAtIndexPath:indexPath]; break; case RedZoneSection: return [self tableView:tableView cellForAreaTwoRowAtIndexPath:indexPath]; break; case TimeOfDaySection: return [self tableView:tableView cellForAreaThreeRowAtIndexPath:indexPath]; break; default: return nil; break; } } 下面是我检查每个部分的行数。 我怀疑我的问题可能在这里,但我不完全确定。 – (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { switch (section) { case AreaOneSection: […]

如何在不使用TableViewController的情况下创build分组的TableView

我有一个UITableView,我想它有2个部分。 我现在知道,如果你使用的是UITableViewController,并且你正在使用静态单元,那么你只能拥有分组的部分。 是我想做的可能吗? 如果是这样的话,我可以在哪里寻求帮助。 看起来像我find的每个教程都是使用UITableViewController的例子。

如何在UITableViewCell中调整图像大小?

我正在尝试使Xcode应用程序具有从JSON文件加载数据的列表。 它基本上有一个标题,副标题和缩略图。 当应用程序加载时,图像与单元格一样大。 我想要将图像调整到一定的大小,或者在单元格之间留出一些额外的空间。 这是我现在的代码: – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"TableCell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; NSDictionary *tempDictionary= [self.googlePlacesArrayFromAFNetworking objectAtIndex:indexPath.row]; NSURL *url = [NSURL URLWithString:[tempDictionary objectForKey:@"icon"]]; NSData *data = [NSData dataWithContentsOfURL:url]; cell.imageView.image = [UIImage imageWithData:data]; CALayer * l = [cell.imageView layer]; [l setCornerRadius:13]; [l setBorderWidth:0.5]; [l setBorderColor:[[UIColor lightGrayColor] […]

UIRefreshControl闪烁

我在iOS 8下遇到了UIRefreshControl的一些闪烁问题。每当我第一次来到我的tableView的顶部(意味着应用程序刚开始的时候),我看到下面gif中显示的闪烁。 这不会发生在任何后来的时间,我到了tableView的顶部,直到这个视图再次加载,所以在我做了一些应用程序的另一个视图或重新启动它。 这是我的应用程序的viewDidLoad()中的代码: let refreshControl = UIRefreshControl() override func viewDidLoad() { super.viewDidLoad() // Doing this here to prevent the UIRefreshControl sometimes looking messed up when waking the app self.refreshControl.endRefreshing() updateData() refreshControl.backgroundColor = UIColor(hue: 0.58, saturation: 1.0, brightness: 0.43, alpha: 1.0) refreshControl.tintColor = UIColor.whiteColor() refreshControl.addTarget(self, action: "updateData", forControlEvents: UIControlEvents.ValueChanged) tableView.addSubview(refreshControl) } refreshControl被声明在viewDidLoad()函数之外,因为我想从我的updateData()函数中调用endRefreshing方法。 这似乎是这样做的显而易见的方式。

如何在一个string中获取UITableView的选定单元格的值

我很确定这很简单。 但是我不能做这个工作。 我有一个UITableView,我dynamic显示一个Facebook的朋友列表,感谢他们的FBID。 基本上,我想返回我select的朋友的FBID,用逗号分隔的一个string。 如果可能的话,在一个IBAction中,所以我可以将它们传递给一个php的参数。 例如,让我们假装我有一个4个朋友的名单,ABCD,他们的ID是1,2,3,4。 如果我selectA和C,我想有一个string,说1,3。 所有我设法做的是显示我select的朋友的ID,一次一个。 这是我的代码: -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { rowcount = [[tableView indexPathsForSelectedRows] count]; indexer = [idFriends objectAtIndex:indexPath.row]; aapell = [NSString stringWithFormat:@"%@", indexer]; NSMutableString * arrayIds = [[NSMutableString alloc] init]; [arrayIds appendString:aapell]; NSLog(@"ids: %@", arrayIds); } 预先感谢您,我确信这并不复杂。

为什么在制作自定义表格视图单元格时使可重复使用的单元格出队两次?

我正在按照使用故事板制作自定义表格视图单元格的教程。 我拖动UILabel作为单元格的子视图,并将它的标记设置为1.我有两个关于数据源代码的问题。 第二次出队声明的目的是什么? 我知道这是一个init方法,而不使用storyboard来定制单元格。 tableview和self.tableview有什么区别? -(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier]; } NSDictionary *dToAccess = (self.tableView==tableView)?[self.arForTable objectAtIndex:indexPath.row] : [self.arForSearch objectAtIndex:indexPath.row]; [(UILabel*)[cell viewWithTag:1] setText:[dToAccess valueForKey:@"name"]]; [(UILabel*)[cell viewWithTag:2] setText:[dToAccess valueForKey:@"value"]]; return cell; }

获取UITableViewCellAccessoryDe​​tailButton的框架(这是零)

我试图从UITableViewCell的accessoryView展示一个popover。 该视图是默认的UITableViewCellAccessoryDetailButton 。 显然accessoryView是nil ,根据这个问题 ,这是一个预期的行为。 我的问题是,即使accessoryView属性为零,我如何获得附件的框架?

在tableviewcontroller中caching图像

我想将图像保存到TableViewcontroller的caching中。 我写了下面的代码,但cacheImage总是为零。 @property (nonatomic,strong)NSCache *imageCache; @synthesize imageCache; – (void)viewDidLoad { [super viewDidLoad]; self.imageCache = [[NSCache alloc] init]; } – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; cell.textLabel.text = [[tableData objectAtIndex:indexPath.row] valueForKey:@"name"]; cell.textLabel.font = [UIFont fontWithName:@"BebasNeue" size:24]; cell.textLabel.textColor = [UIColor whiteColor]; UIImage *cachedImage = [imageCache objectForKey:@"indexObject"]; […]