【发布时间】:2014-01-16 05:25:14
【问题描述】:
我正在使用 UITableView 来显示行数。当我单击该行时,需要长时间单击才能执行操作。我已经检查了这个LINK 它和我的问题一样。但它仍然存在问题。
//表格视图
bookshelfTbaleView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, 250, 150)];
bookshelfTbaleView.delaysContentTouches=NO;
[bookshelfTbaleView setAllowsMultipleSelection:YES];
bookshelfTbaleView.dataSource=self;
bookshelfTbaleView.delegate=self;
bookshelfTbaleView.backgroundColor = [UIColor grayColor];
[bookshelfView addSubview:bookshelfTbaleView];
[scrollview addSubview:popUpBookShelfView];
//TableView 委托方法
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row==0)
{
[popUpBookShelfView removeFromSuperview];
bookShelfClick=0;
}
if (indexPath.row==1)
{
NSLog(@"%@",string);
}
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 2;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 60;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *kCellID = @"cellID";
UITableViewCell *cell = [bookshelfTbaleView dequeueReusableCellWithIdentifier:kCellID];
cell.userInteractionEnabled=YES;
UIFont *myFont = [UIFont fontWithName:@"HelveticaNeue-CondensedBold" size:18];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:kCellID];
//cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
if (tableView==bookshelfTbaleView) {
if (indexPath.row==0) {
cell.textLabel.text=@"All Category";
cell.textLabel.font = myFont;
cell.textLabel.textColor=[UIColor whiteColor];
}
if (indexPath.row==1) {
cell.textLabel.text=@"Downloaded Category";
cell.textLabel.textColor=[UIColor whiteColor];
cell.textLabel.font = myFont;
}
}
return cell;
}
当点击 TableView 中的行时,需要长时间点击才能移动到功能
tableView: didSelectRowAtIndexPath:
这是我在表格视图中得到的值。
谁能解决我的问题。
谢谢。
【问题讨论】:
-
为什么单元格总是为零?
-
在将文本添加到单元格之前,使其为零
-
那么您并没有真正重用单元格,而是在每次调用 cellForRow 时创建一个新单元格。
-
我已经删除了那行代码并检查了,但同样的问题
标签: ios objective-c uitableview