gpt4 book ai didi

iphone - 如何在点击后突出显示电子邮件地址

转载 作者:行者123 更新时间:2023-11-29 04:13:06 25 4
gpt4 key购买 nike

在我的表格 View 中,我有名字、姓氏、电子邮件地址和电话号码。我有网络服务,通过它我可以从服务器获取数据并将其显示在我的设备上。我有一个问题,我从服务器获取的数据显示得很好,但有些电子邮件地址很长,因此可以看到一半的电子邮件地址,后面跟着点点(即 raboert.baderasam11@gma.. ..)。

有什么方法可以让我点击电子邮件地址时,可以看到其所有突出显示的文本或标签,即完整的电子邮件地址?或者任何突出显示电子邮件地址的工具提示?我希望它在单个 View 中而不是多个 View 中。这个任务必须完成。所以请帮助我。我对 iPhone 开发非常陌生。

   here is the code :-


// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath*)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
NSArray* currentListOfItems=nil;
Contact *aContact=nil;
if(searching){
currentListOfItems=searchResult;
aContact=[searchResult objectAtIndex:indexPath.row];
}else{
currentListOfItems=content;
aContact=[[[content objectAtIndex:indexPath.section] objectForKey:@"rowValues"]
objectAtIndex:indexPath.row];
}
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:CellIdentifier];
UILabel *lbl3 = [[UILabel alloc]initWithFrame:CGRectMake(12, 0, 150, 20)];
[lbl3 setTextColor:[UIColor blackColor]];
[lbl3 setFont:[UIFont boldSystemFontOfSize:16.0]];
lbl3.text =[NSString stringWithFormat:@"%@ %@", aContact.lastName,aContact.firstName];
[cell addSubview:lbl3];
UILabel *lbl1 = [[UILabel alloc]initWithFrame:CGRectMake(12, 20, 200, 20)];
[lbl1 setTextColor:[UIColor blackColor]];
[lbl1 setFont:[UIFont boldSystemFontOfSize:12.0]];
lbl1.text = aContact.email;
[cell addSubview:lbl1];
UILabel *lbl2 = [[UILabel alloc]initWithFrame:CGRectMake(210, 20, 300, 20)];
[lbl2 setTextColor:[UIColor grayColor]];
[lbl2 setFont:[UIFont fontWithName:@"Arial" size:12.0]];
lbl2.text = [NSString stringWithFormat:@"%@%@", @"| ",aContact.phone] ;
[cell addSubview:lbl2];
return cell;
}

最佳答案

当用户触摸标签时,您可以更改带有电子邮件地址的标签的宽度。要接收触摸,请在标签上启用 userInteractionEnabled 并添加 UITapGestureRecognizer。在手势识别器的方法中,将 View 属性的宽度更改为手势识别器。

编辑:

标签默认不允许用户交互。为了接收手势,您必须像这样启用用户交互

myLabel.userInteractionEnabled = YES;

要添加 UITapGestureRecognizer,请执行以下操作:

UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(lableWasTapped:)];
[myLabel addGestureRecognizer:tapGestureRecognizer];

要对点击使用react,请执行以下操作:

- (void)lableWasTapped:(UITapGestureRecognizer*)sender {
UILabel *label = (UILabel*)sender.view;
CGSize labelSize = [label.text sizeWithFont:label.font];
CGRect labelFrame = label.frame;
labelFrame.size.width = labelSize.width;
label.frame = labelFrame;
}

关于iphone - 如何在点击后突出显示电子邮件地址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14097865/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com