0

クリックすると、ラベルをクリックしてサファリでURLを開くことができ、電話番号と電子メールアドレスを電子メールで開くことができます

override func viewDidLoad() {
  super.viewDidLoad()

  // DetailsSV.contentSize.height=1120

  print("idis \(self.strUserid)")

  let ref = Firebase(url: "https://businesswallet.firebaseio.com/Users")

  ref.childByAppendingPath(self.strUserid as String).observeEventType(.Value, withBlock: { snapshot in
    if let dict = snapshot.value as? NSMutableDictionary{
      print("dict is \(dict)")
      if let Email = dict["Email"] as? String {
        self.EmailL.text = Email
      }
      if let name = dict["BusinessName"] as? String {
        self.BusinessNameL.text = name
        self.navigationItem.title = name
      }
      if let ShortDescription = dict["ShortDescription"] as? String {
        self.ShortDescriptionL.text = ShortDescription
      }
      if let City = dict["City"] as? String {
        self.CityL.text = City
      }
      if let ContactMe = dict["ContactMe"] as? String {
        self.ContactMeL.text = ContactMe
      }
      if let PhoneNumber = dict["PhoneNumber"] as? String {
        self.PhoneNumberL.text = PhoneNumber
      }
      if let Website1 = dict["Website1"] as? String {
        self.Website1L.text = Website1
      }
      if let Website2 = dict["Website2"] as? String {
        self.Website2L.text = Website2
      }
      if let Category = dict["Category"] as? String {
        self.CategoryL.text = Category
      }
      if let Details = dict["Details"] as? String {
        self.DetailsTV.text = Details
      }
    }
  })

私はこの機能を追加しましたが、機能しません:

if let Website1 = dict["Website1"] as? String {
  self.Website1L.text = Website1
  let weblurl = NSURL(string: "open page:\(Website1)")
  UIApplication.sharedApplication().openURL(weblurl!)
}
4

1 に答える 1

0

UITextView を使用してみてください。ユーザーが UITextView 内のテキストを編集できないようにする場合は、UITextView の属性インスペクターで「編集可能」のチェックを外すことができます。リンク、電話番号、イベント、住所などのテキスト文字列を UITextView で検出できるようにする場合は、UITextView の属性インスペクターで該当するものを確認できます。

表示したいリンクが 1 つしかないことがわかっている場合は、必要なテキストを含むボタンを追加して、ユーザーを Safari に送信します。

于 2016-05-02T19:36:52.483 に答える