Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

url in label (IOS)

How can i make a link in a labeltext on iOS platform?
thanks!

— asked July 17th 2011 by pj nooyen
  • url in label
0 Comments

3 Answers

  • You could use a textarea for this.

    If you don't want the user to edit it you can put it as ' editable: false '.

    To detect the links you can use the property ' autoLink '.

    Here's an example:

    var textarea = Titanium.UI.createTextArea({
        top: 10,
        left: 10,
        right: 10,
        bottom: 10,
        borderRadius: 10,
        editable: false, //This property can be removed if you want the user to edit the text
        width: '90%',
        color: '#888',
        height: '140',
        value: "Value of the field, if it contains an URL like www.google.com it will be highlighted and clickable",
        font: {
            fontSize: 13,
            fontFamily: 'Helvetica-Bold'
        },
        autoLink: Ti.UI.AUTODETECT_ALL
    });
    

    Hope this solves your problem

    Tjeu

    — answered July 18th 2011 by Tjeu Vdw
    permalink
    6 Comments
    • autolink is android only :-( thats why i asked.
      evengoed bedankt tjeu :-)

      — commented July 18th 2011 by pj nooyen
    • Autolink is android only for labels, on a textarea you can use it on iOs ;) use the code I provided, I use it too in my iPhone app.

      — commented July 18th 2011 by Tjeu Vdw
    • Works in iOS, albeit with some caveats. Auto-height does not work on textarea element and no way to style the text or hyperlinks within the textarea.

      — commented July 21st 2011 by Julian Fraser
    • Thanks tjeu! Didnt know that.
      Seems nice nice workaround :0)
      Ill watch the caveats julian,

      — commented July 22nd 2011 by pj nooyen
    • Has Apple approved your application? Cause if it has, this is a definite practical work around. :D

      — commented May 14th 2012 by Nikhil Nigade
    • Titanium.UI.AUTODETECT_ALL DEPRECATED in 1.8.0, in favor of Ti.UI.AUTOLINK_ALL.

      ;)

      — commented January 5th 2013 by Raul Gomez
  • The best way to do this is with a click event listener and calling this in the event listener to the url you desire

    — answered July 18th 2011 by Matt Apperson
    permalink
    0 Comments
  • I'm pretty use you'd need to use a webView to do that on iOS, then use some JS in the head script of the webView contents to fire a custom event back in to your main JS script depending on what you want to happen when a link is clicked.

    — answered July 17th 2011 by Kosso
    permalink
    1 Comment
    • pretty sure … etc… (damn no edit)

      — commented July 17th 2011 by Kosso
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.