내가 일하고있는 Swift 앱이 있습니다. 문의 페이지에는 'Facebook 프로필', 전화 번호, 이메일 주소가 표시됩니다.사용자가 전화를 걸 때 전화를 거는 방법은 무엇입니까?
나는 코드 설정 방법에 대해 이야기를 들었습니다. 예를 들어 전화 번호를 클릭하면 iPhone 전화 다이얼러에서 열립니다.
코드를 찾을 수있는 아이디어가 있습니까?
나는 코드를 알고 있다고 말한 사람으로부터이 코드를 보냈지 만, 코드가 어디로 갔는지 물었을 때 그는 단지 피들을 써야한다고했습니다. 당신은 viewDidLoad
에 대한 액션을 추가해야하는 각 레이블에이 코드를 추가 할 필요가
:
이
는 자신의 코드yourlabel.isUserInteractionEnabled = true
let rc = UITapGestureRecognizer(target: self, action: #selector(YourViewController.yourfunction))
rc.numberOfTapsRequired = 1
rc.numberOfTouchesRequired = 1
yourlabel.addGestureRecognizer(rc)
func yourfunction(recognizer: UITapGestureRecognizer) {
let email = "[email protected]"
let url = NSURL(string: "mailto:\(email)")
UIApplication.sharedApplication().openURL(url)
}
을 그리고 이것은 접촉 페이지에 대한 내 코드 (이다 contactViewController.swift). 누군가 나를 찾아서 나를 도울 수 있습니까?
import UIKit
class contactViewController: UIViewController {
@IBOutlet weak var phone: UILabel!
@IBOutlet weak var mail: UILabel!
@IBOutlet weak var facebook: UILabel!
@IBOutlet weak var instagram: UILabel!
@IBOutlet weak var address: UILabel!
@IBOutlet weak var titleContact: UILabel!
@IBOutlet weak var message: UILabel!
@IBOutlet weak var scroll: UIScrollView!
override func viewDidLoad() {
super.viewDidLoad()
// setup title
self.title = "Contact us"
// setup NavigationBar Color
self.navigationController?.navigationBar.barTintColor = navigationBarColor
// setup side Bar
if(sideBarPosition == "left"){
self.setupLeftMenuButton()
}
else{
self.setupRightMenuButton()
}
// setup page content
scroll.bounces = false
phone.text = phoneNumber
mail.text = emailAdress
facebook.text = facebookAcount
instagram.text = instgramAcount
address.text = adressLocal
titleContact.text = titleContactus
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.lineSpacing = 20
let attrString = NSMutableAttributedString(string: messageContact)
attrString.addAttribute(NSParagraphStyleAttributeName, value:paragraphStyle, range:NSMakeRange(0, attrString.length))
message.attributedText = attrString
message.textAlignment = NSTextAlignment.center
}
// setup left menu button icon
func setupLeftMenuButton() {
let button = UIButton.init(type: .custom)
button.setImage(UIImage.init(named: "menuleft.png")?.withRenderingMode(.alwaysTemplate), for: UIControlState.normal)
button.addTarget(self, action:#selector(leftDrawerButtonPress), for: UIControlEvents.touchUpInside)
button.frame = CGRect.init(x: 0, y: 0, width: 30, height: 17) //CGRectMake(0, 0, 30, 30)
button.imageView?.tintColor = iconColor
let barButton = UIBarButtonItem.init(customView: button)
self.navigationItem.leftBarButtonItem = barButton
}
// setup left menu button action
func leftDrawerButtonPress(_ sender: AnyObject?) {
self.evo_drawerController?.toggleDrawerSide(.left, animated: true, completion: nil)
}
// setup right menu button icon
func setupRightMenuButton() {
let button = UIButton.init(type: .custom)
button.setImage(UIImage.init(named: "menuright.png")?.withRenderingMode(.alwaysTemplate), for: UIControlState.normal)
button.addTarget(self, action:#selector(rightDrawerButtonPress), for: UIControlEvents.touchUpInside)
button.frame = CGRect.init(x: 0, y: 0, width: 30, height: 17) //CGRectMake(0, 0, 30, 30)
button.imageView?.tintColor = iconColor
let barButton = UIBarButtonItem.init(customView: button)
self.navigationItem.rightBarButtonItem = barButton
}
// setup right menu button action
func rightDrawerButtonPress(_ sender: AnyObject?) {
self.evo_drawerController?.toggleDrawerSide(.right, animated: true, completion: nil)
}
}
어떤 생각을 내 코드에 코드를 대체 할 어디? –