Xcode 键盘不显示问题 即设置

今天使用Xcode6写个post demo发现键盘没有中文输入,于是进模拟器设置添加了简体中文,结果发现运行时点击textfiled不会弹出键盘了,键盘虽然可以输入,但只能输入中文,不能切换为英文状态,后来发现Xcode6.0之后模拟器的键盘不支持电脑键盘和模拟器虚拟键盘同时使用了,想要切换可以使用 command+shift+K键进行两种键盘输入的切换
设立同样可使设置键盘

下面再说一下Xcode6模拟器改中文界面

点击Settings选择Ceneral进入Language & Region进入选择语言界面:
设置语言

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在 Xcode 中使用 Swift 在地图上显示标记,并在点击标记时显示弹出窗口,可以使用 MapKit 框架中的 MKMapView 和 MKAnnotationView 类。 首先,需要定义一个实现了 MKAnnotation 协议的类来表示地图上的标记: ``` import MapKit class MyAnnotation: NSObject, MKAnnotation { var coordinate: CLLocationCoordinate2D var title: String? var subtitle: String? init(coordinate: CLLocationCoordinate2D, title: String?, subtitle: String?) { self.coordinate = coordinate self.title = title self.subtitle = subtitle } } ``` 然后,在 ViewController 中添加 MKMapView,并设置其 delegate 属性为 self: ``` import UIKit import MapKit class ViewController: UIViewController, MKMapViewDelegate { @IBOutlet weak var mapView: MKMapView! override func viewDidLoad() { super.viewDidLoad() mapView.delegate = self // 添加标记 let annotation = MyAnnotation(coordinate: CLLocationCoordinate2D(latitude: 37.33182, longitude: -122.03118), title: "Apple Inc.", subtitle: "Cupertino") mapView.addAnnotation(annotation) } // 实现 MKMapViewDelegate 中的方法 func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? { guard let annotation = annotation as? MyAnnotation else { return nil } let identifier = "MyAnnotationView" var annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: identifier) as? MKPinAnnotationView if annotationView == nil { annotationView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: identifier) annotationView?.canShowCallout = true annotationView?.rightCalloutAccessoryView = UIButton(type: .detailDisclosure) } else { annotationView?.annotation = annotation } return annotationView } // 点击详情按钮时触发 func mapView(_ mapView: MKMapView, annotationView view: MKAnnotationView, calloutAccessoryControlTapped control: UIControl) { if let annotation = view.annotation as? MyAnnotation { let alertController = UIAlertController(title: annotation.title, message: annotation.subtitle, preferredStyle: .alert) alertController.addAction(UIAlertAction(title: "OK", style: .default, handler: nil)) present(alertController, animated: true, completion: nil) } } } ``` 在上面的代码中,我们首先在 viewDidLoad 方法中添加了一个 MyAnnotation 标记,并将其添加到 mapView 中。然后,我们实现了 MKMapViewDelegate 中的 viewFor 方法,在其中创建了一个 MKPinAnnotationView,并设置了它的 canShowCallout 属性为 true,表示可以显示弹出窗口,并设置了它的 rightCalloutAccessoryView 属性为一个 UIButton,表示在弹出窗口的右侧添加一个详情按钮。 最后,我们实现了 MKMapViewDelegate 中的 calloutAccessoryControlTapped 方法,当用户点击详情按钮时,会触发这个方法,我们在其中创建了一个 UIAlertController,显示标记的标题和副标题,并在其中添加了一个 OK 按钮来关闭弹出窗口。 这样,当我们运行应用程序时,在地图上就会显示一个名为 "Apple Inc." 的标记,并且当我们点击这个标记时,就会显示一个弹出窗口显示标记的标题和副标题。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值