Как заставить UITextView обнаружить ссылки для веб-сайта, почты и номера телефона

Эта функция выполняет работу без debug_backtrace:

/*
usage :
some code...
getRealCallClass(__FUNCTION__);
some code...
*/

function getRealCallClass($functionName) //Parameter value must always be __FUNCTION__
{
  try
   {
     throw new exception();
   }
  catch(exception $e)
   {
     $trace = $e->getTrace();
     $bInfunction = false;
     foreach($trace as $trace_piece)
      {
          if ($trace_piece['function'] == $functionName)
           {
             if (!$bInfunction)
              $bInfunction = true;
           }
          elseif($bInfunction) //found !!!
           {
             return $trace_piece['class'];
           }
      }
   }
}
51
задан Leo Dabus 5 November 2017 в 19:05
поделиться

2 ответа

Если вы используете OS3.0

, вы можете сделать это следующим образом

textview.editable = NO;
textview.dataDetectorTypes = UIDataDetectorTypeAll;
97
ответ дан 7 November 2019 в 09:53
поделиться

I'm curious, do you have control over the text shown? If so, you should probably just stick it in a UIWebView and throw some links in there to do it "the right way".

0
ответ дан 7 November 2019 в 09:53
поделиться