uitableview 取消重用的section view可否重用

你的位置: >
> iOS UITableView中关于cell里的按钮被点击时如何确定是哪一个section
在section=10;row=1;的UITableView中,每一个cell都带有一个按钮,例如如下的图片一样
每一个cell中都有一个“进入店铺的按钮”,但是如果我点击相应的cell要进入对应的店铺如何处理呢?
如果用”- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath”这个方法的话会的确可以用“indexPath.section”定位到我点击的是哪一个section,但是会使得整个cell都能点击。如果不介意的话这个方法当然可以,下面来说一下只通过按钮来确定是哪一个section的方法。
首先,你的按钮必须要绑定你的事件,和storyBoard拖个线就行了。
然后一定要在storyBoard仔细观察你的button上面一共有几层才能到你的cell,也就是属一下上面有几个父类才到cell
如图所示,方框里的是button,上面到cell一共有三层。为什么要看有几层,我们来看一下按钮的代码
- (IBAction)enterShopButton:(UIButton *)sender {
UIView *v = [sender superview];//获取父类view
UIView *v1 = [v superview];
UITableViewCell *cell = (UITableViewCell *)[v1 superview];//获取cell
NSIndexPath *indexPathAll = [self.tableView indexPathForCell:cell];//获取cell对应的section
NSLog(@&indexPath:--------%@&,indexPathAll);
首先第一个“v”是获取“View”这一层,然后继续调用superview往上翻(不懂的对照上面的图来看)
“v1”是获取“Content View”这一层,
“cell”就获取到了对应的cell这一层。然后取出cell的路径
path = 2 - 0
代表当前cell所在的section,“0”代表当前cell里的row位置。
再通过“indexPathAll.section”就能获取当前的section了。
个人觉得非常好用,而且很容易理解。
本文永久地址:/3400.html本文出自
,转载时请注明出处及相应链接。
与本文相关的文章UITableView的详细讲解
- (NSInteger)numberOfSectionsInTableView:(UITableView
*)tableView
-(NSInteger)tableView:(UITableView
*)tableView
numberOfRowsInSection:(NSInteger)section
-(UITableViewCell
*)tableView:(UITableView
*)tableView
cellForRowAtIndexPath:(NSIndexPath
*)indexPath
-(NSArray*)sectionIndexTitlesForTableView:(UITableView
*)tableView
//设置每个section显示的Title
-(NSString *)tableView:(UITableView
*)tableView
titleForHeaderInSection:(NSInteger)section
&NSString *key = [m_titleArrayobjectAtIndex:section];
//分区的数量
- (NSInteger)numberOfSectionsInTableView:(UITableView
*)tableView
return<span STYLE="letter-spacing:0.0 color:#;
-(NSInteger)tableView:(UITableView
*)tableView
numberOfRowsInSection:(NSInteger)section
&sectionArray = [myDictionary&objectForKey:[m_titleArray&objectAtIndex:section]];
&return [sectionArray&count];
-(UITableViewCell
*)tableView:(UITableView
*)tableView
cellForRowAtIndexPath:(NSIndexPath
*)indexPath
*theSection =
[m_titleArrayobjectAtIndex:indexPath.section];
//NSLog(@"theSection=%@",theSection);
& //声明一个标识符,然后使用它请求可重用单元
&staticNSString *CellIdentifier =@"Cell";
UITableViewCell
*cell = [tableView
dequeueReusableCellWithIdentifier:CellIdentifier];
& //如果没有可重用单元,则创建一个
& //使用前面提到的标识符字符串手动创建一个新的表视图单元。我们将不可避免地重复使用此处创建的单元。
[[[UITableViewCellalloc]initWithStyle:UITableViewCellStyleDefaultreuseIdentifier:CellIdentifier]&autorelease];
& sectionArray = [myDictionaryobjectForKey:theSection];
*singername =
[sectionArrayobjectAtIndex:indexPath.row];
cell.textLabel.text =
& cell.textLabel.font = [UIFontboldSystemFontOfSize:<span STYLE="letter-spacing:0.0 color:#];
cell.imageView.image = [UIImageimageNamed:[NSStringstringWithFormat:@"%@.png",singername]];//未选中cell时的图片
& cell.imageView.highlightedImage = [UIImageimageNamed:@""];//选中cell后的图片
cell.showsReorderControl =YES;
cell.accessoryType
=UITableViewCellAccessoryDetailDisclosureButton;
//把每行的缩进级别设置为其行号,第0号缩进级别为0,第1行缩进级别为1.
- (NSInteger)tableView:(UITableView
*)tableView
indentationLevelForRowAtIndexPath:(NSIndexPath
*)indexPath
&NSUInteger
indexPath.row;
-(CGFloat)tableView:(UITableView
*)tableView
heightForRowAtIndexPath:(NSIndexPath
*)indexPath
&return<span STYLE="letter-spacing:0.0 color:#;
NSIndexPath
[NSIndexPath&indexPathForRow:row&inSection:section];
& [_tableView&selectRowAtIndexPath:ipanimated:YES&scrollPosition:UITableViewScrollPositionNone];
&_tableview.separatorStyle
UITableViewCellSeparatorStyleNone;
-(void)tableView:(UITableView
*)tableView
didSelectRowAtIndexPath:(NSIndexPath
*)indexPath
& [m_tableview&deselectRowAtIndexPath:indexPath&animated:YES];//选中后的反显颜色即刻消失
//选中之前执行(阻止选中第一行)
-(NSIndexPath*)tableView:(UITableView
*)tableView
willSelectRowAtIndexPath:(NSIndexPath
*)indexPath
& NSLog(@"willSelectRowAtIndexPath");
&NSUInteger
[indexPath&row];
&if (row ==
&return indexP
//设置划动cell是否出现del按钮
-(BOOL)tableView:(UITableView
*)tableView
canEditRowAtIndexPath:(NSIndexPath
*)indexPath
& returnYES;
-(void)tableView:(UITableView
*)tableView&
commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath
*)indexPath
(editingStyle
==UITableViewCellEditingStyleDelete)&
[sectionArray&removeObjectAtIndex:indexPath.row];
[m_tableview&deleteRowsAtIndexPaths:[NSMutableArrayarrayWithObjects:indexPath,nil]&withRowAnimation:UITableViewRowAnimationTop];
//在表视图右侧添加一个索引
-(NSArray *)sectionIndexTitlesForTableView:(UITableView
*)tableView
& return&m_titleArray;
//跳到指定的row or
[tableView
scrollToRowAtIndexPath:[NSIndexPath&indexPathForRow:0inSection:0]&atScrollPosition:UITableViewScrollPositionBottom&animated:NO];&
//选中项的风格
cell.selectionStyle =
UITableViewCellSelectionStyleB
cell.accessoryType =
UITableViewCellAccessoryDisclosureI
- (void)tableView:(UITableView
*)tableView
&&&&&&&&didSelectRowAtIndexPath:(NSIndexPath
*)indexPath&
&&&&NSLog(@"Selected
section %d, cell %d",&
indexPath indexAtPosition: 0 ], [ indexPath indexAtPosition: 1
&&&&//获的当前选择项
&&&&UITableViewCell
*cell = [ self.tableView cellForRowAtIndexPath: indexPath
&&&&//显示复选框
(cell.accessoryType == UITableViewCellAccessoryNone)
&&&&&&&&cell.accessoryType
= UITableViewCellAccessoryC
&&&&&&&&cell.accessoryType
= UITableViewCellAccessoryN&
由于设置单元格背景颜色只能在UITextViewDelegate代理函数willDisplayCell中有效,所以在该函数中可以设置颜色交替
//行将显示的时候调用
- (void)tableView:(UITableView
*)tableView
willDisplayCell:(UITableViewCell
forRowAtIndexPath:(NSIndexPath
*)indexPath&
//方法一:
&UIColor *color = ((indexPath.row %<span STYLE="letter-spacing:0.0 color:#) ==<span STYLE="letter-spacing:0.0 color:#) ? [UIColorcolorWithRed:<span STYLE="letter-spacing:0.0 color:#5.0/<span STYLE="letter-spacing:0.0 color:#5green:<span STYLE="letter-spacing:0.0 color:#5.0/<span STYLE="letter-spacing:0.0 color:#5blue:<span STYLE="letter-spacing:0.0 color:#5.0/<span STYLE="letter-spacing:0.0 color:#5alpha:<span STYLE="letter-spacing:0.0 color:#]
: [UIColorclearColor]; &
& cell.backgroundColor
& NSLog(@"willDisplaycell");
& //方法二:
&if (indexPath.row %<span STYLE="letter-spacing:0.0 color:# ==<span STYLE="letter-spacing:0.0 color:#)&
cell.backgroundColor = [UIColoryellowColor];
cell.backgroundColor = [UIColorredColor];
cell.selectedBackgroundView = [[UIImageViewalloc]initWithImage:[UIImageimageNamed:@"cell_1.png"]];//选中cell行变图片
显示文本:&cell.text = @"Frank's Table
对齐:&cell.textAlignment =
UITextAlignmentL
UITextAlignmentLeft
默认是左对齐
&&&UITextAlignmentRight
&&&UITextAlignmentCenter
(3) 字体和尺寸:
UIFont *myFont = [ UIFont
fontWithName: @"Arial" size: 18.0 ];&
cell.font = myF
//系统字体
UIFont *mySystemFont = [ UIFont
systemFontOfSize: 12.0 ];
UIFont *myBoldSystemFont = [
UIFont boldSystemFontOfSize: 12.0 ];
UIFont *myItalicSystemFont = [
UIFont italicSystemFontOfSize: 12.0 ];
//文本颜色
cell.textColor = [UIColor
redColor];
//当前选择cell文本的颜色
cell.selectedTextColor =
[UIColor blueColor];
//从你应用程序目录下的文件创建一个image
cell.image = [UIImage
imageNamed: @"cell.png"];
//当前选中项的图形
cell.selectedImage = [UIImage
imageNamed: @"selected_cell.png" ];//选中cell后左边图片换
//选中后变图片
cell.leftImageView.highlightedImage
[UIImageimageNamed:@"china_national_day-2011-hp.jpg"];
&可以修改table保准行高来适应你的图形高度
= [ super init ];
(self != nil) {
&&&&&&&&self.tableView.rowHeight
&&&&return
你也可以为每一个cell定义不同的高度
(CGFloat)tableView:(UITableView *)tableView
heightForRowAtIndexPath:(NSIndexPath
*)indexPath&
([ indexPath indexAtPosition: 1 ] == 0)
&&&&&&&&return
&&&&&&&&return
UIView *backView =
[[UIView&alloc]initWithFrame:CGRectMake(<span STYLE="letter-spacing:0.0 color:#,<span STYLE="letter-spacing:0.0 color:#,<span STYLE="letter-spacing:0.0 color:#0,<span STYLE="letter-spacing:0.0 color:#)];
cell.selectedBackgroundView = backV
cell.selectedBackgroundView.backgroundColor = [UIColor&orangeColor];
[backView&release];&
设置tableView偏移
tableView内容的偏移值,第一个参数为Y方向
&tableView.contentInset =
UIEdgeInsetsMake(<span STYLE="letter-spacing:0.0 color:#,<span STYLE="letter-spacing:0.0 color:#,<span STYLE="letter-spacing:0.0 color:#,<span STYLE="letter-spacing:0.0 color:#);
修改UITableView中Delete操作的默认按钮
默认的删除按钮为Delete,如果想显示为删除的话,则需要实现UITableViewDelegate中的
- (NSString
*)tableView:(UITableView *)tableView
titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath
*)indexPath方法。
//删除按钮的名字
-(NSString*)tableView:(UITableView
*)tableView
titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath
*)indexPath
& return@"删除按钮";
或者,最简单的方式,将plist中的Localization
native development region改为China即可。
UITableView在didSelectRowAtIndexPath实现双击事件的方法
- (void)tableView:(UITableView
*)tableView
didSelectRowAtIndexPath:(NSIndexPath
*)indexPath
//如果两次点击的时间间隔小于1秒,则断定为双击事件
NSUInteger
[[NSDate&date]&timeIntervalSince1970];
(curr-taptime&&/span&<span STYLE="letter-spacing:0.0 color:#) {
[self&doubleTap];
点击变色再恢复&
[_tableView
deselectRowAtIndexPath:indexPath animated:YES];
分别是折叠状态的tableview和展开状态的tableview
运行效果如下,分别是折叠状态的tabview和展开状态的tabview:
一、新建UITableViewController
&.h文件如下,包含了一个用于显示的视图tableview和用于表示模型数据的MutableArray.
&@interface GDXXDetailVC
:UITableViewController
&UITableView* tableV
&NSMutableArray*
&UIBarButtonItem *btnS
&NSString *account,*
&-(void)setModel:(NSString*)_account
pass:(NSString*)_pass data:(NSArray*)_
&-(void)collapseOrExpand:(int)
&-(Boolean)isExpanded:(int)
.m文件如下,包含了tableview的datasource方法,和模型的处理逻辑。
#import "GDXXDetailVC.h"
@implementation GDXXDetailVC
&-(id)init{
&if(self=[super init]){
&self.title=@"工单处理";
&-(void)setModel:(NSString*)_account
pass:(NSString*)_pass data:(NSArray*)_data
&account=_
&model=[[NSMutableArray alloc]init];
&[model setArray:_data];
&[_data release];
&-(void)loadView{
&self.view=[[UIView
alloc]initWithFrame:CGRectMake(0, 0, 320, 480)];
&tableView=[[UITableView
alloc]initWithFrame:CGRectMake(0, 20, 320, 480)
style:UITableViewStyleGrouped];
&[self.view addSubview:tableView];
&tableView.delegate=
&tableView.dataSource=
&//这个图片中工具栏中显示一个保存按钮
&btnSave= [[UIBarButtonItem alloc]
initWithTitle:@"处理"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(save)];
&self.navigationItem.rightBarButtonItem =
&[btnSave release];
&-(void)saveData{
&#pragma mark Actionsheet 委托方法
&- (void)actionSheet:(UIActionSheet *)actionSheet
clickedButtonAtIndex:(NSInteger)buttonIndex
&{//当ActionSheet的某个按钮被按下时触发
&if(buttonIndex == 0)//第一个按钮表示保存按钮
[self performSelector:@selector(saveData)];
&//解散actionSheet
&[actionSheet dismissWithClickedButtonIndex:
buttonIndex animated:YES];
&#pragma mark ===table view dataSource method and
delegate method===
&//返回分组数
&-(NSInteger)numberOfSectionsInTableView:(UITableView
*)tableView{
&return [model count];
&//返回组标题
&//-(NSString*)tableView:(UITableView *)tableView
titleForHeaderInSection:(NSInteger)section
&// NSDictionary* d=[model
objectAtIndex:section];
&// if(d!=nil)
&//title=[d objectForKey:@"title"];
&//自定义section header
&- (UIView *) tableView: (UITableView *)
&viewForHeaderInSection: (NSInteger) section
NSString*title=@"notitle";
&NSDictionary* d=[model
objectAtIndex:section];
&if(d!=nil)
&title=[d objectForKey:@"title"];
CGRect screenRect = [[UIScreen mainScreen] applicationFrame];
&UIView* footerView = [[UIView alloc]
initWithFrame:CGRectMake(0, 0, screenRect.size.width, 44.0)];
&footerView.autoresizesSubviews = YES;
&footerView.autoresizingMask =
UIViewAutoresizingFlexibleW
&footerView.userInteractionEnabled = YES;
footerView.hidden = NO;
&footerView.multipleTouchEnabled = NO;
&footerView.opaque = NO;
&footerView.contentMode =
UIViewContentModeScaleToF
// Add the label
&UILabel* footerLabel = [[UILabel alloc]
initWithFrame:CGRectMake(64, 5, 120.0, 45.0)];
&footerLabel.backgroundColor = [UIColor
clearColor];
&footerLabel.opaque = NO;
&footerLabel.text =
&footerLabel.textColor = [UIColor
blackColor];
&footerLabel.highlightedTextColor = [UIColor
blueColor];
&footerLabel.font = [UIFont
boldSystemFontOfSize:17];
&footerLabel.shadowColor = [UIColor
whiteColor];
&footerLabel.shadowOffset = CGSizeMake(0.0,
&[footerView addSubview: footerLabel];
[footerLabel release];
// Add the button
&UIButton* footerButton = [[UIButton alloc]
initWithFrame:CGRectMake(12, 5, 48.0, 48.0)];
&//一开始小节是处于“折叠状态”,“+/-”按钮显示“+号”图标
&if ([self isExpanded:section])
{//若本节转换到“展开”状态,需要把图标显示成“-”号
&[footerButton setBackgroundImage:[UIImage
imageNamed:@"minus.png"] forState:UIControlStateNormal];
&[footerButton setBackgroundImage:[UIImage
imageNamed:@"plus.png"] forState:UIControlStateNormal];
&[footerButton addTarget:self
action:@selector(expandButtonClicked:)
&forControlEvents:UIControlEventTouchUpInside];
&footerButton.tag=//把节号保存到按钮tag,以便传递到expandButtonClicked方法
&[footerView addSubview: footerButton];
&[footerButton release];
&// Return the footerView
&return footerV
&//当“+/-”按钮被点击时触发
&-(void)expandButtonClicked:(id)sender{
&UIButton* btn=(UIButton*)
&int section=btn. //取得节号
&[self collapseOrExpand:section];
//刷新tableview
&[tableView reloadData];
&//对指定的节进行“展开/折叠”操作
&-(void)collapseOrExpand:(int)section{
&Boolean expanded=NO;
&NSMutableDictionary* d=[model
objectAtIndex:section];
&//若本节model中的“expanded”属性不为空,则取出来
&if([d objectForKey:@"expanded"]!=nil)
&expanded=[[d
objectForKey:@"expanded"]intValue];
&//若原来是折叠的则展开,若原来是展开的则折叠
&[d setObject:[NSNumber numberWithBool:!expanded]
forKey:@"expanded"];
&//返回指定节的“expanded”值
&-(Boolean)isExpanded:(int)section{
&Boolean expanded=NO;
&NSMutableDictionary* d=[model
objectAtIndex:section];
&//若本节model中的“expanded”属性不为空,则取出来
&if([d objectForKey:@"expanded"]!=nil)
&expanded=[[d
objectForKey:@"expanded"]intValue];
&// 设置header的高度
&- (CGFloat)tableView:(UITableView *)tableView
heightForHeaderInSection:(NSInteger)section {
&return 60;
&//返回分组的行数
&-(NSInteger)tableView:(UITableView *)table
numberOfRowsInSection:(NSInteger)section{
&//对指定节进行“展开”判断
&if (![self isExpanded:section])
{//若本节是“折叠”的,其行数返回为0
&return 0;
&NSDictionary* d=[model
objectAtIndex:section];
&return [[d objectForKey:@"items"] count];
&//设置行高
&-(CGFloat)tableView:(UITableView *)tableView
heightForRowAtIndexPath:(NSIndexPath *)indexPath{
&return 50;
&//设置每一单元格的内容
&-(UITableViewCell*)tableView:(UITableView *)table
cellForRowAtIndexPath:(NSIndexPath *)indexPath{
&static NSString*cellId=@"setcell";
&UITableViewCell* cell=(UITableViewCell*)[table
dequeueReusableCellWithIdentifier:cellId];
&if(cell==nil){
&cell=[[[UITableViewCell
alloc]initWithStyle:UITableViewCellStyleSubtitle
&reuseIdentifier:cellId]autorelease];
&cell.selectionStyle=UITableViewCellSelectionStyleN
&NSDictionary* items=[[model
objectAtIndex:indexPath.section] objectForKey:@"items"];
&keys=[items allKeys];
&cell.textLabel.text=[items objectForKey:[keys
objectAtIndex:indexPath.row]];
&cell.textLabel.font=[UIFont fontWithName:@"Arial"
size:18.0];
&//单元格选中时触发
&-(void)tableView:(UITableView *)table
didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
&-(void)save{
&-(void)dealloc{
&[model release];
&[tableView release];
&[super dealloc];
二、在application的AppDelegate中实例化TableViewController
&在application方法中,构造好一个Array,把要展示的数据放到其中,然后调用TableViewController的setModel方法设置tableview的model。这个Array的结构应该是这样的:
中的元素为NSMutableDictionary(必须是Mutable,不能是NSDictionary)。每一个
NSMutableDictionary代表了一个小节的数据,包含若干key-value,其中Title为小节名称,expanded为小节的展开/
折叠状态,items为小节中每一行的数据。
&- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
window=[[UIWindow alloc]initWithFrame:[[UIScreen
mainScreen]bounds]];
GDXXDetailVC* rootController=[[GDXXDetailVC alloc]init];
&NSMutableArray* items=[[NSMutableArray
alloc]init];
&for (int i=1; i&10; i++) {
&NSDictionary *d=[NSDictionary
dictionaryWithObjectsAndKeys:
&[NSString stringWithFormat:@"section %d
item1",i],@"1",
&[NSString stringWithFormat:@"section %d
item2",i],@"2",
&[NSString stringWithFormat:@"section %d
item3",i],@"3",
&NSMutableDictionary* dic=[NSMutableDictionary
dictionaryWithObjectsAndKeys:
&[NSString stringWithFormat:@"title
%d",i],@"title",
&d,@"items",[NSNumber
numberWithBool:NO],@"expanded",
&//[d release];
&[items addObject:dic];
&//[dic release];
&[rootController setModel:nil pass:nil
data:items];
&//[items release];
&[rootController setTitle:@"无线应用"];
&[window addSubview:rootController.view];
&//[rootController release];
&[window makeKeyAndVisible];
return YES;
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。&&&&自定义UITableView 的 section 选择视图。即在UITableView的左侧(或右侧)增加section的选择框,手指可以滑动选择框迅速选择某个section。
测试环境:
&&[Code4App]编译测试
相关代码:
(15321次查看,5224次下载) 自定义列表中的索引栏(Index Bar)。手指滑动 index bar 时,中间会出现黑色小浮块,并把index Bar上的字显示在黑色小浮块上,黑色小浮块上的字会随手指 index bar 变换。
小编注:感谢开发者@BeyondAbel 发布代码于。
(14009次查看,4790次下载) 自定义列表中的索引栏(Index Bar)外观。手指滑动 index bar 时,index bar 会跟随手指产生阴影效果。
(16120次查看,4593次下载) 实现多种特殊动画效果的列表目录(UITableView index)。可以自定义各种参数,多达20多种,来定义index的外观和动画效果。仅支持iOS 6.0以上
(14616次查看,2126次下载) 实现Path应用的时间滚动条效果:即在列表中,移动滚动条的同时,旁边出现信息标签,用于显示移动到哪个列表单元。
感谢开发者@^_^(/member/fa2e)修改了原代码在iOS 7中的bug。
(19146次查看,2902次下载) 实现Path应用的时间滚动条效果:即在列表中,移动滚动条的同时,旁边出现时间标签,用于显示移动到哪个列表单元,类似于一种时间轴的效果
代码评论:
登录后方可评论
刚巧要做个省市选择的,太感谢了,节省了至少5个小时
登录后方可评论
-控件分类-
-功能分类-iOS UITableView取消SectionView停滞效果_IOS开发-织梦者
当前位置:&>&&>& > iOS UITableView取消SectionView停滞效果
iOS UITableView取消SectionView停滞效果
对网上一些想法做了参考。
第一种方法通过验证觉得不太好(不推荐实用)
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
CGFloat sectionHeaderHeight = 40;
if (scrollView.contentOffset.y&=sectionHeaderHeight&&scrollView.contentOffset.y&=0) {
scrollView.contentInset = UIEdgeInsetsMake(-scrollView.contentOffset.y, 0, 0, 0);
else if (scrollView.contentOffset.y&=sectionHeaderHeight) {
scrollView.contentInset = UIEdgeInsetsMake(-sectionHeaderHeight, 0, 0, 0);
第二种方法:通过对自定义sectionView的setFrame的重写,重新设置section的Y值。
#import "ZWSectionHeadView.h"
#define APP_SCREEN_WIDTH [UIScreen mainScreen].bounds.size.width
// 屏幕的宽度
#define kHeadView_Height 44
@implementation ZWSectionHeadView
#pragma mark - init
#pragma mark -
+ (ZWSectionHeadView *)showWithName:(NSString *)sectionName
ZWSectionHeadView
*sectionView = [[ZWSectionHeadView alloc]initWithFrame:CGRectMake(0, 0, APP_SCREEN_WIDTH, kHeadView_Height)];
sectionView.backgroundColor = [UIColor colorWithRed:0.1 green:0.5 blue:0.8 alpha:0.2f];
UILabel *titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 22, APP_SCREEN_WIDTH - 20, 20)];
titleLabel.textColor = [UIColor blueColor];
titleLabel.text = sectionN
titleLabel.font = [UIFont systemFontOfSize:16.0f];
[sectionView addSubview:titleLabel];
return sectionV
#pragma mark - sectionHeight
+ (CGFloat)getSectionHeight
return kHeadView_H
#pragma mark - setter
- (void)setFrame:(CGRect)frame{
CGRect sectionRect = [self.tableView rectForSection:self.section];
CGRect newFrame = CGRectMake(CGRectGetMinX(frame), CGRectGetMinY(sectionRect), CGRectGetWidth(frame), CGRectGetHeight(frame));
[super setFrame:newFrame];
以上就是iOS UITableView取消SectionView停滞效果的全文介绍,希望对您学习和使用ios应用开发有所帮助.
这些内容可能对你也有帮助
更多可查看IOS开发列表页。
猜您也会喜欢这些文章

我要回帖

更多关于 uitableview 重用 的文章

 

随机推荐