0

テーブル ビューには、名、姓、メール アドレス、電話番号があります。サーバーからデータを取得してデバイスに表示できる Web サービスがあります。問題があります。サーバーからフェッチしているデータは完全に表示されていますが、一部の電子メール アドレスは非常に長いため、電子メール アドレスの半分の後にドット ドットが表示されます (つまり、raboert.baderasam11@gma.. ..)。

電子メール アドレスをタップすると、すべてのテキストまたはラベルが強調表示され、完全な電子メール アドレスが表示されるようにする方法はありますか? または、電子メールアドレスを強調するツールチップはありますか?複数ではなく単一のビューで表示したい. このタスクは実行する必要があります。だから私を助けてください。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;
}
4

1 に答える 1

1

ユーザーがタッチしたときに、メールアドレスでラベルの幅を変更できます。userInteractionEnabledラベルでタッチ イネーブルを受け取り、UITapGestureRecognizer. ジェスチャ レコグナイザーへのメソッドで、ビュー プロパティの幅をジェスチャ レコグナイザーに変更します。

編集:

デフォルトでは、ラベルはユーザーの操作を許可しません。ジェスチャを受け取るには、次のようなユーザー インタラクションを有効にする必要があります。

myLabel.userInteractionEnabled = YES;

を追加するにUITapGestureRecognizerは、次の手順を実行します。

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

タップに反応するには、次を実装します。

- (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;
}
于 2012-12-31T10:16:53.900 に答える