Dip*_*ara 5 objective-c uitableview ios
我的一个奇怪的问题UITableView.每当我按下我的第一行时UITableView,该didDeselectRowAtIndexPath方法都不会被调用.我目前的代码如下.
# pragma mark - UITableViewDelegate & UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [self.ary_tblDisplay count];
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 80;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"TableCell";
UIView *colorView,*backgroundView;
UILabel *lblCode,*lblStatus,*lblDate;
UITableViewCell *cell = (UITableViewCell *) [self.tbl_claims dequeueReusableCellWithIdentifier:CellIdentifier];
cell = nil;
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
colorView = [[UIView alloc] initWithFrame:CGRectMake(7, 5, 5, 70)];
[cell addSubview:colorView];
backgroundView = [[UIView alloc] initWithFrame:CGRectMake(12, 5, 306, 70)];
backgroundView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"LightGreen"]];
[cell addSubview:backgroundView];
lblCode = [[UILabel alloc] initWithFrame:CGRectMake(20, 7, 140, 40)];
lblCode.text = [[self.ary_tblDisplay objectAtIndex:indexPath.row] claim_code];
lblCode.backgroundColor = [UIColor clearColor];
lblCode.textColor = [UIColor blueColor];
lblCode.font = [UIFont boldSystemFontOfSize:18];
[cell addSubview:lblCode];
lblStatus = [[UILabel alloc] initWithFrame:CGRectMake(20, 40, 140, 35)];
lblStatus.backgroundColor = [UIColor clearColor];
lblStatus.text = [[self.ary_tblDisplay objectAtIndex:indexPath.row] claim_status];
[cell addSubview:lblStatus];
lblDate = [[UILabel alloc] initWithFrame:CGRectMake(150, 20, 120, 40)];
lblDate.backgroundColor = [UIColor clearColor];
lblDate.text = [[self.ary_tblDisplay objectAtIndex:indexPath.row] accepted_date];
[cell addSubview:lblDate];
if ([lblStatus.text isEqualToString:@"Rejected"])
colorView.backgroundColor = [UIColor redColor];
else if ([lblStatus.text isEqualToString:@"Accepted"])
colorView.backgroundColor = [UIColor greenColor];
else if ([lblStatus.text isEqualToString:@"In-Progress"])
colorView.backgroundColor = [UIColor blueColor];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.backgroundColor = [UIColor redColor];
return cell;
}
- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
{
StatusViewController *obj_StatusViewController = [[StatusViewController alloc] initWithNibName:IS_IPHONE_5?@"StatusViewController":@"StatusViewController_3.5" bundle:nil];
obj_StatusViewController.details = [self.ary_tblDisplay objectAtIndex:indexPath.row];
[self.navigationController pushViewController:obj_StatusViewController animated:YES];
}
Run Code Online (Sandbox Code Playgroud)
Ani*_*ese 25
你真的是指didDeselectRowAtIndexPath吗?
难怪,didDeselectRowAtIndexPath只有当您取消选择意味着更改选择的行时,才会调用此选项.我怀疑你错误地选择了didDeselectRowAtIndexPath.您可能想要使用didSelectRowAtIndexPath方法
| 归档时间: |
|
| 查看次数: |
3382 次 |
| 最近记录: |