Tag: 可用视图

从UITableView删除最后一行 – 崩溃与NSInternalInconsistencyError

我尝试了所有可search的解决scheme无济于事。 我目前的删除代码如下: [self.conversationsTableView beginUpdates]; [_conversations removeObjectAtIndex:[indexPath row]]; if ([self.conversationsTableView numberOfRowsInSection:indexPath.section] == 1) { [self.conversationsTableView deleteSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationAutomatic]; } else { [self.conversationsTableView deleteRowsAtIndexPaths:@[ indexPath ] withRowAnimation:UITableViewRowAnimationAutomatic]; } [self.conversationsTableView endUpdates]; 正如你所看到的,在删除section / row之前,我在_conversations中正确删除了我的数据源,而且如果它是最后一个,我也删除了这个section。 我仍然崩溃了: 终止应用程序由于未捕获的exception'NSInternalInconsistencyException',原因:'UITableView内部错误:无法生成一个新的部分映射旧节数:1和新的节数:0' 我没有想法,除非我做了一个真正的黑客解决scheme,我在我的实际内容之上插入了一个看不见的部分,而我真的不想这样做。 任何帮助是极大的赞赏。 这是我的numberOfSectionsInTableView看起来像: – (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } 真的很奇怪的更新 :我试图通过插入一个空白部分,因为我删除旧的一个绕过这个哈克的方式。 但是由于一些无法解释的原因,我仍然得到错误。 该错误坚持,即使我已经将我的代码更改为以下内容,tableview有一个新的部分计数为0: if ([self.conversationsTableView numberOfRowsInSection:indexPath.row] == 1) { [self.conversationsTableView deleteSections:[NSIndexSet […]

为什么不能设置cell.selectionStyle = UITableViewCellSelectionStyleBlue?

我已经看到以下问题,但不解释,虽然你可以简单地设置cell.SelectedStyle UITableViewCellSelectionStyleGray或UITableViewCellSelectionStyleNone ,你不能将它的selectionStyle设置为UITableViewCellSelectionStyleBlue 。 他们只是提供一个黑客没有解释。 我只是想知道为什么我可以更好地理解objective-c UITableViewCellSelectionStyleBlue不起作用 ios7 UITableViewCell selectionStyle不会回到蓝色 无法更改UITableView蓝色高亮颜色

尝试使用custon UITableViewCell时发生错误“此类不是键值编码兼容的密钥…”

我已经看到了关于清理笔尖连接的其他问题,但我不相信这是我的问题。 目前我正在导入一个自定义的UITableViewCell类,在VC的viewDidLoad中使用UITableView在VC中注册nib,如下所示: static NSString *cellIdentifier = @"cell"; UINib* cellNib = [UINib nibWithNibName:@"[nib for the custom cell]" bundle:[NSBundle mainBundle]]; [_theTableView registerNib:cellNib forCellReuseIdentifier:cellIdentifier]; 然后在VC中实现这个方法 – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString* cellIdentifier = @"cell"; CustomTableCell* cell = [tableView dequeueReusableCellWithIdentifier:outgoingNoteIdentifier forIndexPath:indexPath]; return cell; } 如果我没有连接自定义单元格中的任何属性(只是标签和button),那么它加载正常,我可以看到与标签和button相关的图像。 当我试图只连接xib文件中的一个属性时,我得到了上面提到的错误。

在UITableView中从networking加载图像的更有效的方法是什么?

对于我的UITableView每个UITableViewCell ,我在后台线程中从网上下载一个图像。 然后我使用主线程更新单元格中的imageView。 dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void){ //Background Thread // download the image in separate thread UIImage *image = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString: @"someurl.com" ] ] ]; dispatch_async(dispatch_get_main_queue(), ^(void){ // this is called in the main thread after the download has finished, here u update the cell's imageView with the new image cell.eventImageView.image = […]

使用多个自定义的UITableViewCells

我正在尝试实现分组样式的UITableView,如联系应用程序detailedView。 我想最上面的单元格是透明的,并在底部有一个UISegemtedControl。 当我尝试创build两种不同types的自定义单元格时,即使使用两个不同的cellIdentifiers,也只会加载第一个自定义单元格。 将不胜感激索姆的指导。 或者针对同一主题的一些很好的教程技巧。 – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { /* UIView *backView = [[UIView alloc] initWithFrame:CGRectZero]; backView.backgroundColor = [UIColor clearColor]; cell.backgroundView = backView; [backView release]; */ static NSString *cellIdentifier1 = @"DetailCellStyle1"; static NSString *cellIdentifier2 = @"DetailCellStyle2"; if (indexPath.section == 0) { // Load from nib DetailCellViewController *cell = (DetailCellViewController *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier1]; if […]

自定义表视图单元格

我为我的UITableView创build了一个自定义的UITableView Cell类。 但是,由于某些原因,我无法在单元格中设置值。 就像在userName和userImage这样的值不会显示何时加载表。 这个问题已经持续了几天。 下面是我的代码,为了简单起见,我使用了虚拟值。 如果有人可以请让我知道我做错了,这将不胜感激。 谢谢! 码 CustomCell.h @interface CustomCell : UITableViewCell { IBOutlet UILabel *userName; IBOutlet UIImageView *userImage; } @property(strong,nonatomic) IBOutlet UILabel *userName; @property(strong,nonatomic) IBOutlet UIImageView *userImage; @end CustomCell.m #import "CustomCell.h" @interface CustomCell () @end @implementation CustomCell @synthesize userName; @synthesize userImage; -(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) […]

当UITableView完全重新加载

我有一个控件,部分或完全改变tableView的内容。 发生更改后,我设置了一个标志tableViewContentHasChanged : BOOL tableViewContentHasChanged = YES; [self.tableView reloadData]; tableViewContentHasChanged = NO; 我的问题出现在tableView:viewForHeaderInSection: 它在表视图重新加载后调用,所以我的标志在该方法内无效。 简而言之,当桌子完全重新加载时,观察正确的方式是什么,所以我可以将标志设置为NO ? 而且,我可能做错了什么?

单击UITableview单元格内的search时出现错误的结果

在tableview的单元格中,我有一个button。 该button基本上打开单元格引用的文件。 这是工作正常,而search不上。 但是,search时,我似乎无法得到search结果数组中的正确的行。 这是我迄今为止所尝试的:在cellForRowAtIndexPath标记button。 myDownloadsBtn = (UIButton *) [cell viewWithTag:106]; 行动设置如下: [myDownloadsBtn addTarget:self action: @selector(downloadClicked:event:) forControlEvents:UIControlEventTouchUpInside]; 然后在downloadClicked我有以下 NSSet *touches = [event allTouches]; UITouch *touch = [touches anyObject]; NSString *todoRow; CGPoint currentTouchPosition = [touch locationInView:self->tableview]; NSIndexPath *indexPath = [self->tableview indexPathForRowAtPoint: currentTouchPosition]; 但是它给了我VISIBLE当前位置的indexPath,而不是search结果数组中行的位置。 此外,我的委托方法的didSelectRowAtIndexPath正常工作,没有search。 这只是单元格内的button。 我发现这个问题,但没有答案: 如何在iOS中search时获得选定的tableviewbutton值 。 其他问题涉及如何知道search时select的实际单元格,但这不是我的问题。 谢谢。

设置SWTableViewCell

我想利用开源的UITableViewCell子类SWTableViewClass但SWTableViewClass问题。 我收到的响应“重新定义一个不同types的单元格* _strong vs UITableView * _strong”这是我的代码: – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"FactorCell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; } SWTableViewCell *cell = (SWTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { NSMutableArray *leftUtilityButtons = [NSMutableArray new]; NSMutableArray *rightUtilityButtons = […]

缺省实现中缺lessUITableViewCell detailTextLabel

这似乎是一个重复的问题,但我已阅读所有主题,我还没有find我的答案,所以我决定发表一个新的问题。 我正在使用UITableViewCellStyleSubtitle默认实现,但detailTextLabel不会出现,除非我每次创build一个新的单元格。 这是代码 – (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view from its nib. [tblvUsersList registerClass:[UITableViewCell class] forCellReuseIdentifier:@"Cell"]; } – (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { // Return the number of sections. return 1; } – (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { // Return the number of rows in the section. return (self.registeredUser && […]