Select 在 table 视图上不起作用吗?
Did Select not work on table view?
如果我有 table 带有自定义单元格的视图。然后我想从 table 的 select 视图中获得不同的视图.. 那么我怎样才能做同样的事情我的代码在这里。
[CCTableView registerNib:[UINib nibWithNibName:@"CCCustomCell" bundle:nil] forCellReuseIdentifier:@"CellIdentifier"];
[CCTableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
arraySuper=[NSMutableArray new];
NSUserDefaults *userSave = [NSUserDefaults standardUserDefaults];
NSArray *KeysArray=[NSArray arrayWithObjects:[NSString stringWithFormat:@"Welcome - %@",[userSave valueForKey:@"userID"]], nil];
NSArray *objectArray=[NSArray arrayWithObjects:@"", nil];
[self bindValues:KeysArray withObjects:objectArray];
NSArray *KeysArray1=[NSArray arrayWithObjects:@"Case Status",@"Open Delivery Cases",@"Open Claim Cases",@"Feedback Awaiting",@"Completed Good",@"Completed bad", nil];
NSArray *objectArray1=[NSArray arrayWithObjects:@"",openDelieveryCase,openClaimCase,@"0",completeGood,@"0", nil];
[self bindValues:KeysArray1 withObjects:objectArray1];
NSArray *KeysArray2=[NSArray arrayWithObjects:@"Today's Reminder",@"Case #123456 - Update Request by the insurer. Send Insurance Proof.1",@"Case #123456 - Update Request by the insurer. Send Insurance Proof.2",@"Case #123456 - Update Request by the insurer. Send Insurance Proof.3",@"Case #123456 - Update Request by the insurer. Send Insurance Proof.4", nil];
NSArray *objectArray2=[NSArray arrayWithObjects:@"",@"",@"",@"",@"", nil];
[self bindValues:KeysArray2 withObjects:objectArray2];
}
-(void)bindValues:(NSArray*) KeysArray withObjects:(NSArray*)objectArray
{
NSMutableArray *arrayMain=[NSMutableArray new];
for (int i=0;i<[KeysArray count];i++) {
NSDictionary *dict=[NSDictionary dictionaryWithObject:[objectArray objectAtIndex:i] forKey:[KeysArray objectAtIndex:i]];
[arrayMain addObject:dict];
}
[arraySuper addObject:arrayMain];
}
// ̄ ̄
#pragma mark - Button Menu
#pragma mark-
-(void)buttonMenu:(UIButton *)button
{
[self.menuContainerViewController toggleLeftSideMenuCompletion:nil];
}
//
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView
{
return arraySuper.count;
}
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [[arraySuper objectAtIndex:section] count];
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath
{
static NSString *cellIdentifier=@"CellIdentifier";
//CCCustomCell *cell
cell=[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell==nil) {
cell=[[CCCustomCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}
cell.keyText.text=[[[[arraySuper objectAtIndex:indexPath.section] objectAtIndex:indexPath.row] allKeys] objectAtIndex:0];
cell.objectText.text=[[[[arraySuper objectAtIndex:indexPath.section] objectAtIndex:indexPath.row] allObjects] objectAtIndex:0];
[cell.objectText addConstraint:[NSLayoutConstraint constraintWithItem:cell.objectText
attribute:NSLayoutAttributeWidth
relatedBy:NSLayoutRelationEqual
toItem:nil
attribute:NSLayoutAttributeHeight
multiplier:1.0
constant:(cell.objectText.text.length>0)?50:0]];
if (indexPath.row==0)
{
cell.keyText.textColor=[UIColor blueColor];
cell.keyText.font=[UIFont fontWithName:@"Helvetica-Bold" size:15];
}
else
{
cell.keyText.textColor=[UIColor lightGrayColor];
cell.keyText.font=[UIFont fontWithName:@"Helvetica" size:13];
cell.objectText.textColor=[UIColor blueColor];
cell.objectText.font=[UIFont fontWithName:@"Helvetica" size:13];
}
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath: (NSIndexPath *)indexPath
{
cell.keyText.text=[[[[arraySuper objectAtIndex:indexPath.section] objectAtIndex:indexPath.row] allKeys] objectAtIndex:0];
cell.objectText.text=[[[[arraySuper objectAtIndex:indexPath.section] objectAtIndex:indexPath.row] allObjects] objectAtIndex:0];
[cell.objectText addConstraint:[NSLayoutConstraint constraintWithItem:cell.objectText
attribute:NSLayoutAttributeWidth
relatedBy:NSLayoutRelationEqual
toItem:nil
attribute:NSLayoutAttributeHeight
multiplier:1.0
constant: (cell.objectText.text.length>0)?50:0]];
if (indexPath.row==1)
{
NSLog(@"Csase Status Data");
DetailCaseStatus *caseStatus = [[DetailCaseStatus alloc]initWithNibName:@"DetailCaseStatus" bundle:nil];
[self.navigationController pushViewController:caseStatus animated:YES];
}
}
你能试试吗indexPath.section ==(你想比较的部分)
如果我有 table 带有自定义单元格的视图。然后我想从 table 的 select 视图中获得不同的视图.. 那么我怎样才能做同样的事情我的代码在这里。
[CCTableView registerNib:[UINib nibWithNibName:@"CCCustomCell" bundle:nil] forCellReuseIdentifier:@"CellIdentifier"];
[CCTableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
arraySuper=[NSMutableArray new];
NSUserDefaults *userSave = [NSUserDefaults standardUserDefaults];
NSArray *KeysArray=[NSArray arrayWithObjects:[NSString stringWithFormat:@"Welcome - %@",[userSave valueForKey:@"userID"]], nil];
NSArray *objectArray=[NSArray arrayWithObjects:@"", nil];
[self bindValues:KeysArray withObjects:objectArray];
NSArray *KeysArray1=[NSArray arrayWithObjects:@"Case Status",@"Open Delivery Cases",@"Open Claim Cases",@"Feedback Awaiting",@"Completed Good",@"Completed bad", nil];
NSArray *objectArray1=[NSArray arrayWithObjects:@"",openDelieveryCase,openClaimCase,@"0",completeGood,@"0", nil];
[self bindValues:KeysArray1 withObjects:objectArray1];
NSArray *KeysArray2=[NSArray arrayWithObjects:@"Today's Reminder",@"Case #123456 - Update Request by the insurer. Send Insurance Proof.1",@"Case #123456 - Update Request by the insurer. Send Insurance Proof.2",@"Case #123456 - Update Request by the insurer. Send Insurance Proof.3",@"Case #123456 - Update Request by the insurer. Send Insurance Proof.4", nil];
NSArray *objectArray2=[NSArray arrayWithObjects:@"",@"",@"",@"",@"", nil];
[self bindValues:KeysArray2 withObjects:objectArray2];
}
-(void)bindValues:(NSArray*) KeysArray withObjects:(NSArray*)objectArray
{
NSMutableArray *arrayMain=[NSMutableArray new];
for (int i=0;i<[KeysArray count];i++) {
NSDictionary *dict=[NSDictionary dictionaryWithObject:[objectArray objectAtIndex:i] forKey:[KeysArray objectAtIndex:i]];
[arrayMain addObject:dict];
}
[arraySuper addObject:arrayMain];
}
// ̄ ̄
#pragma mark - Button Menu
#pragma mark-
-(void)buttonMenu:(UIButton *)button
{
[self.menuContainerViewController toggleLeftSideMenuCompletion:nil];
}
//
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView
{
return arraySuper.count;
}
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [[arraySuper objectAtIndex:section] count];
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath
{
static NSString *cellIdentifier=@"CellIdentifier";
//CCCustomCell *cell
cell=[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell==nil) {
cell=[[CCCustomCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}
cell.keyText.text=[[[[arraySuper objectAtIndex:indexPath.section] objectAtIndex:indexPath.row] allKeys] objectAtIndex:0];
cell.objectText.text=[[[[arraySuper objectAtIndex:indexPath.section] objectAtIndex:indexPath.row] allObjects] objectAtIndex:0];
[cell.objectText addConstraint:[NSLayoutConstraint constraintWithItem:cell.objectText
attribute:NSLayoutAttributeWidth
relatedBy:NSLayoutRelationEqual
toItem:nil
attribute:NSLayoutAttributeHeight
multiplier:1.0
constant:(cell.objectText.text.length>0)?50:0]];
if (indexPath.row==0)
{
cell.keyText.textColor=[UIColor blueColor];
cell.keyText.font=[UIFont fontWithName:@"Helvetica-Bold" size:15];
}
else
{
cell.keyText.textColor=[UIColor lightGrayColor];
cell.keyText.font=[UIFont fontWithName:@"Helvetica" size:13];
cell.objectText.textColor=[UIColor blueColor];
cell.objectText.font=[UIFont fontWithName:@"Helvetica" size:13];
}
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath: (NSIndexPath *)indexPath
{
cell.keyText.text=[[[[arraySuper objectAtIndex:indexPath.section] objectAtIndex:indexPath.row] allKeys] objectAtIndex:0];
cell.objectText.text=[[[[arraySuper objectAtIndex:indexPath.section] objectAtIndex:indexPath.row] allObjects] objectAtIndex:0];
[cell.objectText addConstraint:[NSLayoutConstraint constraintWithItem:cell.objectText
attribute:NSLayoutAttributeWidth
relatedBy:NSLayoutRelationEqual
toItem:nil
attribute:NSLayoutAttributeHeight
multiplier:1.0
constant: (cell.objectText.text.length>0)?50:0]];
if (indexPath.row==1)
{
NSLog(@"Csase Status Data");
DetailCaseStatus *caseStatus = [[DetailCaseStatus alloc]initWithNibName:@"DetailCaseStatus" bundle:nil];
[self.navigationController pushViewController:caseStatus animated:YES];
}
}
你能试试吗indexPath.section ==(你想比较的部分)