小编Moh*_*ani的帖子

在greift中将gregorian datepicker转换为波斯语日期选择器?

如何在Swift语言中将Gregorian datepicker转换为波斯语日期选择器?

func datePickerValueChanged(sender: UIDatePicker) {

    let dateFormatter = NSDateFormatter()

    dateFormatter.dateStyle = NSDateFormatterStyle.MediumStyle

    dateFormatter.timeStyle = NSDateFormatterStyle.NoStyle
    dateFormatter.dateFormat = NSCalendarIdentifierPersian

    dateOutlet.text = dateFormatter.stringFromDate(sender.date)

}
Run Code Online (Sandbox Code Playgroud)

我更改了日期格式,NSCalendarIdentifierPersian但datepicker没有任何变化?

uidatepicker ios swift

7
推荐指数
1
解决办法
3759
查看次数

当键盘出现在 Swift 中时,UITextField 会向上移动

我使用此代码在键盘出现时向上移动视图,在我的登录页面中此代码运行良好,但在注册页面中它不起作用。

func textFieldDidBeginEditing(textField: UITextField) {
    animateViewMoving(true, moveValue: 100)
}
func textFieldDidEndEditing(textField: UITextField) {
    animateViewMoving(false, moveValue: 100)
}

func animateViewMoving (up:Bool, moveValue :CGFloat){
    var movementDuration:NSTimeInterval = 0.3
    var movement:CGFloat = ( up ? -moveValue : moveValue)
    UIView.beginAnimations( "animateView", context: nil)
    UIView.setAnimationBeginsFromCurrentState(true)
    UIView.setAnimationDuration(movementDuration )
    self.view.frame = CGRectOffset(self.view.frame, 0,  movement)
    UIView.commitAnimations()
}
Run Code Online (Sandbox Code Playgroud)

我有另一个功能可以返回键盘上的键,它也可以在登录页面上运行,但在注册页面上不起作用。两页之间的所有内容都相同。

  func textFieldShouldReturn(textField: UITextField) -> Bool {

    textField.resignFirstResponder()
    return true
}
Run Code Online (Sandbox Code Playgroud)

keyboard-events uitextfield ios swift

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

标签 统计

ios ×2

swift ×2

keyboard-events ×1

uidatepicker ×1

uitextfield ×1