func textFieldDidBeginEditing(textField: UITextField) {
scrlView.setContentOffset(CGPointMake(0, textField.frame.origin.y-70), animated: true)
if(textField == firstDigit){
textField.becomeFirstResponder()
secondDigit.resignFirstResponder()
}
else if(textField == secondDigit){
textField.becomeFirstResponder()
thirdDigit.resignFirstResponder()
}
else if(textField == thirdDigit){
//textField.becomeFirstResponder()
fourthDigit.becomeFirstResponder()
}
Run Code Online (Sandbox Code Playgroud)
我使用四个文本字段进行OTP输入,其中一次只能输入一个数字.输入数字后,我需要将光标自动移动到下一个文本字段.
我已经尝试了下面的代码:但它显示错误无法将float类型的值转换为预期的参数类型CLLocation degrees(又名Double)
let lat = self.mallData.valueForKey("lat") as! Float
let lon = self.mallData.valueForKey("lon")
let mapLocation : CLLocationCoordinate2D = CLLocationCoordinate2DMake(lat, lon)
Run Code Online (Sandbox Code Playgroud) 我在tableView中使用自定义单元格,但是当我运行时,我得到了我在问题中提到的错误.
self.districtTableView.register(UINib(nibName: "PlaceCollectionViewCell", bundle: nil), forCellReuseIdentifier: "placeCell")
func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool {
return false
}
func textFieldDidEndEditing(_ textField: UITextField) {
// TODO: Your app can do something when textField finishes editing
print("The textField ended editing. Do something based on app requirements.")
}
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return districts.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = …Run Code Online (Sandbox Code Playgroud) let latitude:CLLocationDegrees = 76.0100
let longitude:CLLocationDegrees =25.3620
let location:CLLocationCoordinate2D = CLLocationCoordinate2DMake(latitude, longitude)
let latDelta:CLLocationDegrees = 1
let lonDelta:CLLocationDegrees = 1
let span:MKCoordinateSpan = MKCoordinateSpanMake(latDelta, lonDelta)
let region:MKCoordinateRegion = MKCoordinateRegionMake(location, span)
mapView.setRegion(region, animated: true)
let annotation:MKPointAnnotation = MKPointAnnotation()
annotation.coordinate = location
annotation.title = "Office ."
annotation.subtitle = "My Office"
func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
print("Locations = \(locations)")
let userLocation: CLLocation = locations[0] as CLLocation
//var latitude:CLLocationDegrees = userLocation.coordinate
//var longitude:CLLocationDegrees = -121.934048
//var location:CLLocationCoordinate2D = CLLocationCoordinate2DMake(latitude, longitude)
let latDelta:CLLocationDegrees …Run Code Online (Sandbox Code Playgroud)