iOS中交叉登录的附件类型
我有一个表格视图和2个自定义单元格。我想使用(X)符号,即十字符号和勾号符号。我知道对于勾号,我们有UITableViewCellAccessoryCheckmark,但如何处理(X)符号。我们可以为这个定制配件吗?或者如何实现 我的代码:iOS中交叉登录的附件类型,ios,iphone,objective-c,Ios,Iphone,Objective C,我有一个表格视图和2个自定义单元格。我想使用(X)符号,即十字符号和勾号符号。我知道对于勾号,我们有UITableViewCellAccessoryCheckmark,但如何处理(X)符号。我们可以为这个定制配件吗?或者如何实现 我的代码: #pragma mark - Table View Methods - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } - (NSInteg
#pragma mark - Table View Methods
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 2;
}
- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
optionsLabelArray = [[NSArray alloc] initWithObjects:@"Yes", @"No", nil];
static NSString *CellIdentifier = @"CheckerCell";
CustomCell *cell =[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
cell.optionLabel.text = [optionsLabelArray objectAtIndex:indexPath.row];
cell.optionLabelSubtitle.text = [optionsLabelSubtitleArray objectAtIndex:indexPath.row];
if(indexPath.row == 0)
{
cell.textLabel.textColor = [UIColor colorWithRed:78/255.0 green:157/255.0 blue:19/255.0 alpha:1.0];
}
else if(indexPath.row == 1)
{
cell.textLabel.textColor = [UIColor colorWithRed:167/255.0 green:19/255.0 blue:43/255.0 alpha:1.0];
}
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (tableView ==_optionsTableView1) {
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
previousSelectedCell1.accessoryType = UITableViewCellAccessoryNone;
cell.accessoryType=UITableViewCellAccessoryCheckmark;
previousSelectedCell1 = cell;
NSLog(@"Row : %ld", (long)indexPath.row);
if(indexPath.row == 0)
{
self.weatherSafeToPlay = YES;
}
else
{
// MatchDayDataController *sharedController = [MatchDayDataController sharedDataController];
// sharedController.actions = [sharedController.actions stringByAppendingString:@"Check Weather. "];
//[sharedController.actions appendString:@"Check Weather. "];
self.weatherSafeToPlay = NO;
}
NSLog(@"Is Weather safe: %hhd", self.weatherSafeToPlay);
}
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
您可以将自己的映像分配给表格单元格的accessoryView。创建(X)符号的图像,并将该图像用作accessoryView
cell.accessoryView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"Your X Image"]];
您可以将自己的映像分配给表格单元格的accessoryView。创建(X)符号的图像,并将该图像用作accessoryView
cell.accessoryView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"Your X Image"]];
您可以将自己的映像分配给表格单元格的accessoryView。创建(X)符号的图像,并将该图像用作accessoryView
cell.accessoryView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"Your X Image"]];
您可以将自己的映像分配给表格单元格的accessoryView。创建(X)符号的图像,并将该图像用作accessoryView
cell.accessoryView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"Your X Image"]];
没有听说过cross的任何附件类型,但在这种情况下,我只使用unicode字符。
它比使用图像更轻,只需更改文本即可
- @“\u2713”用于✓李>
- @“\u2717”用于✗李>
或…不使用自定义单元格时,例如:
-(UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(cell == nil) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier];
}
//set your text to cell.textLabel.text
//create your own UILabel
UILabel *lblAcc = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 32, 32)];
[lblAcc setTag:100];
[lblAcc setText:@"?"];
[lblAcc setBackgroundColor:[UIColor redColor]];
[lblAcc setTextAlignment:NSTextAlignmentCenter];
//set as custom AccessoryView on cell
[cell setAccessoryView:lblAcc];
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
NSString *strAccessory = [(UILabel *) [cell viewWithTag:100] text];
//the -isEqualToString is a bit heavier than checking a simple bool or int value
//so since you should be remembering the selected cells anyways, you can change
//the if-logic to compare with a bool rather than the string comparison.
//but for now, we'll do:
if([strAccessory isEqualToString:@"\u2713"]) {
[(UILabel *) [cell viewWithTag:100] setText:@"\u2717"];
}
else {
[(UILabel *) [cell viewWithTag:100] setText:@"\u2713"];
}
}
有关更多unicode字符。。。此链接:
没有听说过cross的任何附件类型,但在这种情况下,我只使用unicode字符。
它比使用图像更轻,只需更改文本即可
- @“\u2713”用于✓李>
- @“\u2717”用于✗李>
或…不使用自定义单元格时,例如:
-(UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(cell == nil) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier];
}
//set your text to cell.textLabel.text
//create your own UILabel
UILabel *lblAcc = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 32, 32)];
[lblAcc setTag:100];
[lblAcc setText:@"?"];
[lblAcc setBackgroundColor:[UIColor redColor]];
[lblAcc setTextAlignment:NSTextAlignmentCenter];
//set as custom AccessoryView on cell
[cell setAccessoryView:lblAcc];
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
NSString *strAccessory = [(UILabel *) [cell viewWithTag:100] text];
//the -isEqualToString is a bit heavier than checking a simple bool or int value
//so since you should be remembering the selected cells anyways, you can change
//the if-logic to compare with a bool rather than the string comparison.
//but for now, we'll do:
if([strAccessory isEqualToString:@"\u2713"]) {
[(UILabel *) [cell viewWithTag:100] setText:@"\u2717"];
}
else {
[(UILabel *) [cell viewWithTag:100] setText:@"\u2713"];
}
}
有关更多unicode字符。。。此链接:
没有听说过cross的任何附件类型,但在这种情况下,我只使用unicode字符。
它比使用图像更轻,只需更改文本即可
- @“\u2713”用于✓李>
- @“\u2717”用于✗李>
或…不使用自定义单元格时,例如:
-(UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(cell == nil) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier];
}
//set your text to cell.textLabel.text
//create your own UILabel
UILabel *lblAcc = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 32, 32)];
[lblAcc setTag:100];
[lblAcc setText:@"?"];
[lblAcc setBackgroundColor:[UIColor redColor]];
[lblAcc setTextAlignment:NSTextAlignmentCenter];
//set as custom AccessoryView on cell
[cell setAccessoryView:lblAcc];
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
NSString *strAccessory = [(UILabel *) [cell viewWithTag:100] text];
//the -isEqualToString is a bit heavier than checking a simple bool or int value
//so since you should be remembering the selected cells anyways, you can change
//the if-logic to compare with a bool rather than the string comparison.
//but for now, we'll do:
if([strAccessory isEqualToString:@"\u2713"]) {
[(UILabel *) [cell viewWithTag:100] setText:@"\u2717"];
}
else {
[(UILabel *) [cell viewWithTag:100] setText:@"\u2713"];
}
}
有关更多unicode字符。。。此链接:
没有听说过cross的任何附件类型,但在这种情况下,我只使用unicode字符。
它比使用图像更轻,只需更改文本即可
- @“\u2713”用于✓李>
- @“\u2717”用于✗李>
或…不使用自定义单元格时,例如:
-(UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(cell == nil) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier];
}
//set your text to cell.textLabel.text
//create your own UILabel
UILabel *lblAcc = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 32, 32)];
[lblAcc setTag:100];
[lblAcc setText:@"?"];
[lblAcc setBackgroundColor:[UIColor redColor]];
[lblAcc setTextAlignment:NSTextAlignmentCenter];
//set as custom AccessoryView on cell
[cell setAccessoryView:lblAcc];
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
NSString *strAccessory = [(UILabel *) [cell viewWithTag:100] text];
//the -isEqualToString is a bit heavier than checking a simple bool or int value
//so since you should be remembering the selected cells anyways, you can change
//the if-logic to compare with a bool rather than the string comparison.
//but for now, we'll do:
if([strAccessory isEqualToString:@"\u2713"]) {
[(UILabel *) [cell viewWithTag:100] setText:@"\u2717"];
}
else {
[(UILabel *) [cell viewWithTag:100] setText:@"\u2713"];
}
}
有关更多unicode字符。。。此链接:
tableViewCell.accessoryView=[[UIImageView alloc]initWithImage:[UIImageName:@“DisclosureViewX”];你的建议很好,但我有两行,现在我设置了两张图片是(勾选)和否(X)。两者同时出现,但一次只能显示一个。知道如何隐藏以一次只带一个吗?tableViewCell.accessoryView=[[UIImageView alloc]initWithImage:[UIImageName:@“DispositionViewX”];你的建议很好,但我有两行,现在我设置了两张图片是(勾选)和否(X)。两者同时出现,但一次只能显示一个。知道如何隐藏以一次只带一个吗?tableViewCell.accessoryView=[[UIImageView alloc]initWithImage:[UIImageName:@“DispositionViewX”];你的建议很好,但我有两行,现在我设置了两张图片是(勾选)和否(X)。两者同时出现,但一次只能显示一个。知道如何隐藏以一次只带一个吗?tableViewCell.accessoryView=[[UIImageView alloc]initWithImage:[UIImageName:@“DispositionViewX”];你的建议很好,但我有两行,现在我设置了两张图片是(勾选)和否(X)。两者同时出现,但一次只能显示一个。你知道如何隐藏一次只带一个吗?你的建议很好,但我有两行,现在我设置了两个图像是(勾选)和否(X)。两者同时出现,但一次只能显示一个。知道如何隐藏一次只带一个吗?如果(index path.row==0){cell.accessoryType=UITableViewCellAccessoryCheckmark;}或者{cell.accessoryView=[[UIImageView alloc]initWithImage:[uiImageName:@“Your X Image”]];}这样行吗?或者您首先要为同一行显示(是),然后显示(x)?spaleja有两行。。默认情况下,不应显示任何内容。单击第2行时,应显示X并单击第1行,但不能同时单击两者。-(void)tableView:(UITableView*)