UITableView的常用代理方法
2015-08-21 15:16
423 查看
//设置行高
- (CGFloat)tableView:(UITableView )tableView heightForRowAtIndexPath:(NSIndexPath )indexPath{
}
//分区
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 3;
}
//设置每个区有多少行共有多少行
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 2;
}
//设置区域的名称
- (NSString )tableView:(UITableView )tableView titleForHeaderInSection:(NSInteger)section;
{
return @”123”;
}
//是否允许行移动
-(BOOL)tableView:(UITableView )tableView canMoveRowAtIndexPath:(NSIndexPath )indexPath
{
}
//响应点击事件
- (void)tableView:(UITableView )tableView didSelectRowAtIndexPath:(NSIndexPath )indexPath
{
NSLog(@”响应单击事件”);
}
//小按钮的响应事件
- (void)tableView:(UITableView )tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath )indexPath
{
NSLog(@”accessoryButton的响应事件”);
}
//删除按钮的名字
-(NSString*)tableView:(UITableView )tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath )indexPath
{
return @”删除”;
}
//设置滑动,
-(BOOL)tableView:(UITableView )tableView canEditRowAtIndexPath:(NSIndexPath )indexPath
{
//ruturn NO不实现滑动
return YES;
}
-(UITableViewCellEditingStyle)tableView:(UITableView )tableView editingStyleForRowAtIndexPath:(NSIndexPath )indexPath
{
NSLog(@”手指撮动了”);
return UITableViewCellEditingStyleDelete;
// //插入
// return UITableViewCellEditingStyleInsert;
}
设置CELL的样式
// cell.selectionStyle = UITableViewCellSelectionStyleBlue;
//灰色
// cell.selectionStyle = UITableViewCellSelectionStyleGray;
//无颜色
// cell.selectionStyle = UITableViewCellSelectionStyleNone;
//向右箭头样式
// cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
//向右箭头button
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
UITableViewCellStyleDefault,// Simple cell with text label and optional image view (behavior of UITableViewCell in iPhoneOS 2.x)
UITableViewCellStyleValue1,// Left aligned label on left and right aligned label on right with blue text (Used in Settings)
UITableViewCellStyleValue2,// Right aligned label on left with blue text and left aligned label on right (Used in Phone/Contacts)
UITableViewCellStyleSubtitle
- (CGFloat)tableView:(UITableView )tableView heightForRowAtIndexPath:(NSIndexPath )indexPath{
return 80;
}
//分区
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 3;
}
//设置每个区有多少行共有多少行
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 2;
}
//设置区域的名称
- (NSString )tableView:(UITableView )tableView titleForHeaderInSection:(NSInteger)section;
{
return @”123”;
}
//是否允许行移动
-(BOOL)tableView:(UITableView )tableView canMoveRowAtIndexPath:(NSIndexPath )indexPath
{
return YES;
}
//响应点击事件
- (void)tableView:(UITableView )tableView didSelectRowAtIndexPath:(NSIndexPath )indexPath
{
NSLog(@”响应单击事件”);
}
//小按钮的响应事件
- (void)tableView:(UITableView )tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath )indexPath
{
NSLog(@”accessoryButton的响应事件”);
}
//删除按钮的名字
-(NSString*)tableView:(UITableView )tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath )indexPath
{
return @”删除”;
}
//设置滑动,
-(BOOL)tableView:(UITableView )tableView canEditRowAtIndexPath:(NSIndexPath )indexPath
{
//ruturn NO不实现滑动
return YES;
}
-(UITableViewCellEditingStyle)tableView:(UITableView )tableView editingStyleForRowAtIndexPath:(NSIndexPath )indexPath
{
NSLog(@”手指撮动了”);
return UITableViewCellEditingStyleDelete;
// //插入
// return UITableViewCellEditingStyleInsert;
}
设置CELL的样式
// cell.selectionStyle = UITableViewCellSelectionStyleBlue;
//灰色
// cell.selectionStyle = UITableViewCellSelectionStyleGray;
//无颜色
// cell.selectionStyle = UITableViewCellSelectionStyleNone;
//向右箭头样式
// cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
//向右箭头button
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
UITableViewCellStyleDefault,// Simple cell with text label and optional image view (behavior of UITableViewCell in iPhoneOS 2.x)
UITableViewCellStyleValue1,// Left aligned label on left and right aligned label on right with blue text (Used in Settings)
UITableViewCellStyleValue2,// Right aligned label on left with blue text and left aligned label on right (Used in Phone/Contacts)
UITableViewCellStyleSubtitle
相关文章推荐
- UVA 123 Searching Quickly
- 从UIImage的矩阵变换看矩阵运算的原理
- iOS摄像头和相册-UIImagePickerController-浅析
- iOS UIView设置背景图片
- Android stduio NDK开发
- 快速理解RequireJs
- UIView实现动画效果
- AsyncTask介绍
- UIView之userInteractionEnabled属性介绍
- hdu5412CRB and Queries(整体二分)
- WPF:如何在工作线程中更新窗体的UI元素(Dispatcher机制)
- UIView 的Transform。(旋转,缩放,3D旋转)
- UIScrollView
- 自定义UIPageControl 的Circle 与其他实现方式有几行代码改动,亲自试过
- iOS 3D UI---CALayer的transform扩展
- [LeetCode] Unique Paths
- forward与include转发问题(RequestDispatcher.include()(乱码问题分析及解决)
- Mix and Build(简单DP)
- Mix and Build(简单DP)
- UITextField详解