[英]'UITabBarDelegate' cannot be constructed because it has no accessible initializers
[英]Initializers Type Cannot be constructed because it has no accessible initializer
我在标题中提到了上面的问题,此porgram用于IOS 8.2作为目标,但是当我在我的Xcode中使用它时,它显示错误,因为目标是8.0,请提前感谢:)
我的代码在下面给出,我需要它用于目标8.0
import UIKit
import MapKit
import CoreLocation
let kGeotificationLatitudeKey = "latitude"
let kGeotificationLongitudeKey = "longitude"
let kGeotificationRadiusKey = "radius"
let kGeotificationIdentifierKey = "identifier"
let kGeotificationNoteKey = "note"
let kGeotificationEventTypeKey = "eventType"
enum EventType: Int {
case OnEntry = 0
case OnExit = 1
}
class Geotification: NSObject, NSCoding, MKAnnotation {
var coordinate: CLLocationCoordinate2D
var radius: CLLocationDistance
var identifier: String
var note: String
var eventType: EventType
var title: String {
if note.isEmpty {
return "No Note"
}
return note
}
var subtitle: String {
var eventTypeString = eventType == .OnEntry ? "On Entry" : "On Exit"
return "Radius: \(radius)m - \(eventTypeString)"
}
init(coordinate: CLLocationCoordinate2D, radius: CLLocationDistance, identifier: String, note: String, eventType: EventType) {
self.coordinate = coordinate
self.radius = radius
self.identifier = identifier
self.note = note
self.eventType = eventType
}
// MARK: NSCoding
required init(coder decoder: NSCoder) {
let latitude = decoder.decodeDoubleForKey(kGeotificationLatitudeKey)
let longitude = decoder.decodeDoubleForKey(kGeotificationLongitudeKey)
coordinate = CLLocationCoordinate2D(latitude: latitude, longitude: longitude)
radius = decoder.decodeDoubleForKey(kGeotificationRadiusKey)
identifier = decoder.decodeObjectForKey(kGeotificationIdentifierKey) as String
note = decoder.decodeObjectForKey(kGeotificationNoteKey) as String
eventType = EventType(decoder.decodeIntegerForKey(kGeotificationEventTypeKey))
}
func encodeWithCoder(coder: NSCoder) {
coder.encodeDouble(coordinate.latitude, forKey: kGeotificationLatitudeKey)
coder.encodeDouble(coordinate.longitude, forKey: kGeotificationLongitudeKey)
coder.encodeDouble(radius, forKey: kGeotificationRadiusKey)
coder.encodeObject(identifier, forKey: kGeotificationIdentifierKey)
coder.encodeObject(note, forKey: kGeotificationNoteKey)
coder.encodeInt(Int32(eventType.rawValue, forKey: kGeotificationEventTypeKey))
}
}
1-)在左侧面板上选择项目根目录
2-)在常规->部署信息窗口中,您可以设置目标。
兄弟,您已经更新了Xcode,并将代码与以前的IOS版本一起使用。 您应该在8.2中搜索如何初始化这些变量。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.