uitableview

tableView组头 组尾滑动

元气小坏坏 提交于 2020-03-08 17:27:23
今天布局tableview 要组头组尾滑动 从网上找的代码 很实用 留下来 每天进步一下 - (void)scrollViewDidScroll:(UIScrollView *)scrollView { if (scrollView == self.detailsTableView) { UITableView *tableview = (UITableView *)scrollView; CGFloat sectionHeaderHeight = 50; CGFloat sectionFooterHeight = 60; CGFloat offsetY = tableview.contentOffset.y; if (offsetY >= 0 && offsetY <= sectionHeaderHeight) { tableview.contentInset = UIEdgeInsetsMake(-offsetY, 0, -sectionFooterHeight, 0); }else if (offsetY >= sectionHeaderHeight && offsetY <= tableview.contentSize.height - tableview.frame.size.height - sectionFooterHeight) { tableview

UITableView中Cell点击展开方法

你说的曾经没有我的故事 提交于 2020-03-07 13:31:17
定义一个属性记录selectedIndexPath用来记录选中的行的indexpath,在视图控制器初始化方法中初始化此属性为nil, 在tableView:didSelectRowAtIndexPath代理方法中: 首先deselect这个行 然后[tableView beginUpdate] if(selectedIndexPath==nil) { selectedIndexPath=indexPath; [tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationAutomatic]; } else{ bool hasSelectedOtherRow=![self.selectedIndexPath isEqualTo:indexPath]; NSIndexPath *temp=self.selectedIndexPath; self.selectedIndexPath=nil; [tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:temp] withRowAnimation:UITableViewRowAnimationAutomatic]; if

UITableViewCell的重用机制和解决方法

这一生的挚爱 提交于 2020-03-06 15:09:29
UITableView为了做到显示与数据的分离, 单独使用了一个叫UITableViewCell的视图用来显示每一行的数据, 而tableView得重用机制就是每次只创建屏幕显示区域内的cell,通过重用标识符identifier来标记cell, 当cell要从屏幕外移入屏幕内时, 系统会从重用池内找到相同标识符的cell, 然后拿来显示, 这样本是为了减少过大的内存使用, 但在很多时候, 我们会自定义cell,这时就会出现一些我们不愿意看到的现象, 下面就介绍一些解决这些问题的方法 UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath]; // 这句代码就是造成cell的重用的代码 在cell中我布局了左边一个imageView, 右边一个Label, 总共显示20行 1 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 2 MyTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"

Change bool status for all objects of all cells in the tableView

≯℡__Kan透↙ 提交于 2020-03-06 04:59:32
问题 Each cell in my tableView has various properties: class: Item // properties var name: String var photo: UIImage? var category: String var instructions: String var completed = false (everything is initialized as well) my tableView array is: items = [Item]() When Item.complete is true, the cell will have a checkmark accessory, else it'll have .none I want to use a UIButton (in a separate VC) to make Item.complete = false for every cell in the tableView, thus removing all of the checkmarks and

Change bool status for all objects of all cells in the tableView

徘徊边缘 提交于 2020-03-06 04:59:24
问题 Each cell in my tableView has various properties: class: Item // properties var name: String var photo: UIImage? var category: String var instructions: String var completed = false (everything is initialized as well) my tableView array is: items = [Item]() When Item.complete is true, the cell will have a checkmark accessory, else it'll have .none I want to use a UIButton (in a separate VC) to make Item.complete = false for every cell in the tableView, thus removing all of the checkmarks and

UITableView refresh problems with an NSURLConnection-asynchronously laden NSMutableArray

房东的猫 提交于 2020-03-05 21:40:05
问题 I am currently approaching Swift (I have been coding in Objective-C for some years) and I am trying to develop a companion app to my video-surveillance system. What my app do is: Connect to a password-protected web site and obtain a list of the last snapshots uploaded by either one of the three existing ip-cameras. For each of these shots, I create a PicInfo object with a temporary pic. I then attempt to asynchronously download the pics and store them in an UIImage property. From there, I

Weird animations when editing custom cell?

瘦欲@ 提交于 2020-03-04 21:31:12
问题 I created a UITableViewCell in Xcode 4 using IB. But for some weird reason when I trigger my edit button, the cell acts really weird and doesn't have the same animations as a normal table view cell. I don't know what is happening, I tried implementing -(void)setEditing:(BOOL)editing animated:(BOOL)animated in my custom cell class but still nothing works. UPDATE: My ViewController that I am using the cell in, has this code under cellForAtIndex to display the cell. CustomCell *cell =

Weird animations when editing custom cell?

拈花ヽ惹草 提交于 2020-03-04 21:27:50
问题 I created a UITableViewCell in Xcode 4 using IB. But for some weird reason when I trigger my edit button, the cell acts really weird and doesn't have the same animations as a normal table view cell. I don't know what is happening, I tried implementing -(void)setEditing:(BOOL)editing animated:(BOOL)animated in my custom cell class but still nothing works. UPDATE: My ViewController that I am using the cell in, has this code under cellForAtIndex to display the cell. CustomCell *cell =

iOS UI控件详解—「UICollectionView综合视图」

烂漫一生 提交于 2020-03-04 11:04:17
Write in the first【写在最前】 UITableView 熟悉吧, UICollectionView 必须熟悉吧。 在 WWDC2012 中的 Introducing Collection Views ,苹果首次介绍了 UICollectionView ,类似 UITableView 的用法使人很容易接受,但强大的自定义布局,又使其相较于 UITableView 有了选择它的更多理由, UITableView 中的表格只支持单排列表,没有办法支持网格列表模式, CollectionView 有着灵活的布局特性,这一点充分说明我们在学会 UITableView 的基础上,再去学习推敲 CollectionView 的必要性。 本篇文章主要从【 UICollectionView 系统文件注解】学习总结。 在「时间 & 知识 」有限内,总结的文章难免有「未全、不足 」的地方,还望各位好友指出,以提高文章质量。 目录: UICollectionView概念 UICollectionView基本组成 UICollectionView层次结构 1.UICollectionView 继承于 UIScrollView 2.UICollectionViewDataSource数据源 3.UICollectionViewDelegate代理 4

UIMenuController/UIPasteboard(2) UITableView上实用剪贴板

╄→гoц情女王★ 提交于 2020-03-04 02:10:17
在UITableView上实用剪贴板有两种方法: 一、在tableView的代理方法中直接有三个有关剪贴板的方法。 //某行是否允许show菜单 -(BOOL)tableView:(UITableView *)tableView shouldShowMenuForRowAtIndexPath:(NSIndexPath *)indexPath { return YES; } //show菜单中能使用的功能 -(BOOL)tableView:(UITableView *)tableView canPerformAction:(SEL)action forRowAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender { if (action == @selector(cut:)){ return YES; } else if(action == @selector(copy:)){ return YES; } else if(action == @selector(paste:)){ return YES; } else if(action == @selector(select:)){ return NO; } else if(action == @selector(selectAll:)){ return YES; }