iOS Question [Solved] textview links

Jamie8763

Active Member
Licensed User
I'm using a TextView and trying to put a hyperlink in the view it works perfect when used on iphone 5c iOS 10 but I've tested it on a iPhone 7 and its not working.

Are their any additional steps that are needed in later builds of iOS?

B4X:
Sub Linkify(tv As TextView)
   Dim no As NativeObject = tv
   no.SetField("editable", False)
   no.SetField("dataDetectorTypes", 0xffffffff)
End Sub

Example:
 

Attachments

  • small.zip
    2.1 KB · Views: 104
Last edited:

BillMeyer

Well-Known Member
Licensed User
Upvote 0

Jamie8763

Active Member
Licensed User
Hi thanks for your fast suggestion the csbuilder would solve the issue of making the links clickable but not detectable the field
dataDetectorTypes must have changed between versions?

The ATS isn't a issue in the project i just made a small example to show the issue between different versions.
 
Upvote 0

Pooya1

Active Member
Licensed User
I used below code
B4X:
Dim cs As CSBuilder
cs.Initialize
cs.Alignment("ALIGN_RIGHT")
cs    =    Miniature.MarkPatternCSbuilder(lbldesc,cs,lbldesc.Text,1)
lbldesc.AttributedText    =    cs.PopAll

Sub MarkPatternCSbuilder(Textview2 As TextView,CS As CSBuilder,Input As String, GroupNumber As Int) As CSBuilder
   
   Pattern   =   "((([a-zA-Z0-9\~\!\@\#\$\%\^\&\*\(\)_\-\=\+\\\/\?\.\:\;\'\,])+)|(http(s)?://([\w+?\.\w+])+([a-zA-Z0-9\~\!\@\#\$\%\^\&\*\(\)_\-\=\+\\\/\?\.\:\;\'\,\s]*)?))"
   
   Dim lastMatchEnd As Int = 0
   Dim m As Matcher = Regex.Matcher(Pattern, Input)
   
   Do While m.Find
       
       Dim currentStart As Int = m.GetStart(GroupNumber)
       Dim temp As String
       temp   =   Input.SubString2(lastMatchEnd, currentStart)
       CS.Append(temp)
       lastMatchEnd = m.GetEnd(GroupNumber)

       Dim temp As String
       temp   =   m.Group(GroupNumber)
       
       If Regex.IsMatch("(http(s)?://([\w+?\.\w+])+([a-zA-Z0-9\~\!\@\#\$\%\^\&\*\(\)_\-\=\+\\\/\?\.\:\;\'\,]*)?)",temp) Then
           CS.Color(Colors.RGB(91,35,179))
           CS.Alignment("ALIGN_LEFT")
           CS.Link(temp)
           CS.Append(temp)
           CS.Pop.Pop
       
       Else If Regex.IsMatch("([a-zA-Z0-9\~\!\@\#\$\%\^\&\*\(\)_\-\=\+\\\/\?\.\:\;\'\,\s])+",temp) Then
           CS.Color(Textview2.TextColor)
           CS.Font(Textview2.Font)
           CS.Alignment("ALIGN_LEFT")
           CS.Append(temp)
           CS.Pop.Pop
           
       Else
           CS.Color(Textview2.TextColor)
           CS.Font(Textview2.Font)
           CS.Alignment("ALIGN_RIGHT")
           CS.Append(temp)
           CS.Pop.Pop
           
       End If
   Loop
   
   If lastMatchEnd < Input.Length Then
       CS.Font(Textview2.Font)
       CS.Append(Input.SubString(lastMatchEnd)).Pop
   End If
   
   Return CS
   
End Sub
 
Upvote 0

Jamie8763

Active Member
Licensed User
The most inconsistent thing is the original code snippet works on the simulator using latest iOS but not the real device.
 
Upvote 0
Top