小编Ade*_*ici的帖子

无法将'[String:String?]'类型的值转换为预期的参数类型'[String:AnyObject?]'

我是Swift的新手,我遵循了这个教程:http://www.raywenderlich.com/90971/introduction-mapkit-swift-关于MapKit的教程.问题是我在这行代码上遇到了错误

let placemark = MKPlacemark(coordinate: self.coordinate, addressDictionary: addressDict)
Run Code Online (Sandbox Code Playgroud)

标题上描述了错误.包含此行的方法是:

func mapItem() -> MKMapItem {
    let addressDict = [String(kABPersonAddressStreetKey): self.subtitle]
    let placemark = MKPlacemark(coordinate: self.coordinate, addressDictionary: addressDict)

    let mapItem = MKMapItem(placemark: placemark)
    mapItem.name = self.title

    return mapItem
}
Run Code Online (Sandbox Code Playgroud)

请帮忙.

iphone mapkit ios swift

10
推荐指数
1
解决办法
6215
查看次数

'title'的类型与协议'MKAnnotation'所需的选项不同

我在swift中遵循了Ray Wenderlich MapKit教程:http://www.raywenderlich.com/90971/introduction-mapkit-swift-tutorial ,当我创建Artwork类时,我得到了标题中写的错误.我不知道自己要做什么.这是代码:

class Artwork: NSObject, MKAnnotation {
let title: String
let locationName: String
let discipline: String
let coordinate: CLLocationCoordinate2D

init(title: String, locationName: String, discipline: String, coordinate: CLLocationCoordinate2D) {
    self.title = title
    self.locationName = locationName
    self.discipline = discipline
    self.coordinate = coordinate

    super.init()
}
}
Run Code Online (Sandbox Code Playgroud)

请帮忙!

iphone mapkit ios swift ios9.1

10
推荐指数
1
解决办法
5541
查看次数

可以在目标c中使用swift中的数组简化概念吗?

我在Swift中有这行代码:

let graphPoints:[Int] = [4, 2, 6, 4, 5, 8, 3]

let average = graphPoints.reduce(0, combine: +) / graphPoints.count
Run Code Online (Sandbox Code Playgroud)

可以在目标c代码中"翻译"这行代码吗?

对于我来说,减少组合概念的工作原理并不是很清楚.我读过它但仍不清楚.

我从本教程中获取了代码:http://www.raywenderlich.com/90693/modern-core-graphics-with-swift-part-2

请帮忙.谢谢.

arrays reduce ios swift

8
推荐指数
1
解决办法
1972
查看次数

更改UIAlertController选择的按钮颜色

我有这行代码:

UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:nil preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:cancelTitle style:UIAlertActionStyleCancel handler:^(UIAlertAction * action) {
    NSLog(@"cancel registration");
}];
[alertController addAction:cancelAction];
alertController.view.tintColor = [UIColor redColor];
Run Code Online (Sandbox Code Playgroud)

我想在选择时更改取消按钮颜色.我怎样才能做到这一点?请帮忙.

objective-c ios swift uialertcontroller

4
推荐指数
1
解决办法
4101
查看次数

标签 统计

ios ×4

swift ×4

iphone ×2

mapkit ×2

arrays ×1

ios9.1 ×1

objective-c ×1

reduce ×1

uialertcontroller ×1