【发布时间】:2018-04-05 11:22:34
【问题描述】:
我尝试调整从 UIView 在 xib 文件中创建的自定义信息窗口的大小。宽度取决于窗口的内容,但我没有找到任何解决方案。我尝试了情节提要中的所有内容,但没有任何反应。我有上传截图看看我的问题:
这是我在 xib 的 UIView 中的代码
public protocol nonPaidDelegate: class {
func didTapMapsSelectButton()
}
class MapInfoWindow: UIView {
@IBOutlet weak var titleInfo: UILabel!
@IBOutlet weak var adressInfo: UILabel!
@IBOutlet weak var buttonAction: UIButton!
open var delegate:nonPaidDelegate?
@IBAction func didTapInButton(_ sender: Any) {
self.delegate?.didTapMapsSelectButton()
print("button tapped")
}
class func instanceFromNib() -> UIView {
return UINib(nibName: "MapInfoWindowView", bundle: nil).instantiate(withOwner: self, options: nil).first as! UIView
}
在我的视图控制器中,我调用 MapInfoWindow
var infoWindow = MapInfoWindow()
infoWindow = loadNiB()
我为标记创建 infoWindow UIView:
func mapView(_ mapView: GMSMapView, markerInfoWindow marker: GMSMarker) -> UIView? {
if let venueItem = marker.userData as? Venue {
infoWindow.titleInfo?.text = venueItem.name
infoWindow.adressInfo?.text = venueItem.locationName
NSLog(venueItem.name!)
} else {
NSLog("Did tap a normal marker")
}
return UIView()
}
}
【问题讨论】:
-
不清楚到底是什么问题。应该发生什么以及正在发生什么?您应该在哪里实现它的代码?我们不知道你在做什么,你想做什么,结果是什么。
-
你使用了多少个标签?
-
你们是对的,我用一些代码更新了我的问题
标签: ios swift xib autoresize