小编Rak*_*han的帖子

如何以编程方式在swift ios中自动将光标从一个文本字段移动到另一个文本字段?

    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输入,其中一次只能输入一个数字.输入数字后,我需要将光标自动移动到下一个文本字段.

ios uitextfielddelegate swift

11
推荐指数
3
解决办法
2万
查看次数

如何将纬度和经度转换为swift中的浮点值

我已经尝试了下面的代码:但它显示错误无法将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)

mkmapview ios swift

6
推荐指数
1
解决办法
1915
查看次数

我收到一个错误 - nib必须包含一个顶级对象,该对象必须是UITableViewCell实例'"

我在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)

uitableview tableviewcell ios swift3

6
推荐指数
6
解决办法
9555
查看次数

如何使用Swift iOS在Mapview中添加两个注释?

 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)

mkmapview ios swift

2
推荐指数
1
解决办法
4650
查看次数