Я использую SDK Google Maps, и в настоящее время у меня есть карта, которая будет маршрутизировать пользователя из любого места в определенное место. Я хотел бы, чтобы пользователь мог вводить туда, куда захочет, а не всегда маршрутизироваться в одно и то же место. Я добавил текстовое поле в графический интерфейс, и всякий раз, когда я запускаю приложение в симуляторе и нажимаю текстовое поле, клавиатура не появляется, и она действует так, как будто я не нажимал на нее.Текстовое поле не работает после нажатия на симулятор
Вот как я создал свой проект:
import UIKit
import GoogleMaps
import GooglePlaces
import CoreData
class ViewController: UIViewController, CLLocationManagerDelegate, UITextFieldDelegate
{
let locationManager = CLLocationManager()
var currLocation: CLLocationCoordinate2D!
var keyy = "myKeyIsHere"
var didFindMyLocation = false
var count: Int = 0
var button = UIButton()
var latitude = UITextField()
var longitude = UITextField()
var path = GMSMutablePath()
super.viewDidLoad()
let blah = GMSCameraPosition.camera(withLatitude: 39.8282, longitude: -98.5795, zoom: 25.0)
mapView.camera = blah
locationManager.delegate = self
locationManager.requestWhenInUseAuthorization()
mapView.addObserver(self, forKeyPath: "myLocation", options: NSKeyValueObservingOptions.new, context: nil)
currLocation = mapView.myLocation?.coordinate
button = UIButton(type: .system)
button.frame = CGRect(x: 135, y: 40, width: 100, height: 40)
button.backgroundColor = UIColor.clear
button.layer.cornerRadius = 5
button.layer.borderWidth = 1
button.layer.borderColor = UIColor.blue.cgColor
button.setTitle("Route", for: UIControlState.normal)
button.addTarget(self, action: #selector(ViewController.buttonPressed), for: UIControlEvents.touchUpInside)
latitude = UITextField()
latitude.frame = CGRect(x: 5, y: 90, width: 175, height: 35)
latitude.backgroundColor = UIColor.white
latitude.layer.cornerRadius = 5
latitude.layer.borderWidth = 1
latitude.layer.borderColor = UIColor.black.cgColor
latitude.isUserInteractionEnabled = true
latitude.text = " Enter Latitude"
latitude.keyboardType = UIKeyboardType.numbersAndPunctuation
self.latitude.delegate = self
longitude = UITextField()
longitude.frame = CGRect(x: 195, y: 90, width: 175, height: 35)
longitude.backgroundColor = UIColor.white
longitude.layer.cornerRadius = 5
longitude.layer.borderWidth = 1
longitude.layer.borderColor = UIColor.black.cgColor
longitude.isUserInteractionEnabled = true
longitude.text = " Enter Longitude"
longitude.keyboardType = UIKeyboardType.numbersAndPunctuation
self.longitude.delegate = self
self.view.addSubview(latitude)
self.view.addSubview(button)
self.view.addSubview(longitude)
}
Там есть больше, но это все, что я чувствую, имеет отношение к этой проблеме. Я действительно добавил два текстовых поля здесь, и ни одна из них не работает! Пожалуйста помоги!
вид интересная проблема. Вы тестируете его в своем симуляторе? –
ive попробовал использовать симулятор, а также с помощью моего собственного телефона! – skyleguy
Поскольку я создаю все мои элементы GUI в контроллере представления, должен ли я просто удалить main.storyboard целиком? – skyleguy