小编sum*_*esh的帖子

如何使用Swift打开Goog​​le地图以显示路线

我在互联网上阅读,但找不到合法的答案.当用户点击按钮显示路线时,我需要打开Goog​​le地图.必须自动填写开始和目的地.

我怎样才能在Swift中实现这一目标?

如果有人有解决方案,请提供示例代码.开始始终是用户的当前位置.

google-maps ios swift

35
推荐指数
10
解决办法
4万
查看次数

如何在swift中按下按钮取消localNotification?

我正在UILocalNotification通过单击按钮来安排位置.但是当我尝试通过再次单击相同的按钮取消localNotification时,它不会取消通知.我正在使用UIApplication.sharedApplication().cancelLocalNotification(localNotification) 取消我的预定位置的本地通知.我究竟做错了什么 ?这是我的实施

@IBAction func setNotification(sender: UIButton!) {
    if sender.tag == 999 {
        sender.setImage(UIImage(named: "NotificationFilled")!, forState: .Normal)
        sender.tag = 0
        regionMonitor() //function where notification get scheduled

    } else {
        sender.setImage(UIImage(named: "Notification")!, forState: .Normal)
        sender.tag = 999 }
Run Code Online (Sandbox Code Playgroud)

我该怎么进入else块,以便取消预定的通知.无法清除所有通知.这是didEnterRegion我触发本地通知的块代码

func locationManager(manager: CLLocationManager!, didEnterRegion region: CLRegion!) {
    localNotification.regionTriggersOnce = true
    localNotification.alertBody = "Stack Overflow is great"
    UIApplication.sharedApplication().scheduleLocalNotification(localNotification)
    NSLog("Entering region")
}
Run Code Online (Sandbox Code Playgroud)

iphone ios uilocalnotification swift ios8

17
推荐指数
2
解决办法
2万
查看次数

如何在不使用tag的情况下更改tableviewCell中的图像按钮

我在tableview单元格中有一个按钮.我希望最初按钮有一个图像"A",当用户点击它时,它会变为"B",当用户再次点击它时它会变回"A".

让这两个图像为"A"和"B"在这个场景中我无法使用,tag因为我用它来确定用户点击了哪个按钮indexPath.row

下面是我的按钮功能的当前状态.

@IBAction func setNotification(sender: UIButton!) {

        cell = tableView.cellForRowAtIndexPath(NSIndexPath(forRow: sender.tag, inSection: 0)) as! CustomTableViewCell

        sender.setImage(UIImage(named: "B")!, forState: .Normal)
currentRegion = CLCircularRegion(center: CLLocationCoordinate2D(latitude: latitude ,longitude:longitude), radius: 10, identifier: "xyz")
Run Code Online (Sandbox Code Playgroud)

这也是我的cellForRowAtIndexPath功能看起来的样子

cell.notifybutton.addTarget(self, action: "setNotification:", forControlEvents: UIControlEvents.TouchUpInside)
        cell.notifybutton.setImage(UIImage(named: "A"), forState: UIControlState.Normal)
        cell.notifybutton.tag = indexPath.row
Run Code Online (Sandbox Code Playgroud)

iphone uitableview ios swift

3
推荐指数
1
解决办法
1905
查看次数

如何在swift中取消特定的UILocalNotification?

我在表视图中有一个单元格,其中有一个用于安排通知的按钮.是否可以删除或取消该特定单元格的通知而不影响其他单元格安排的通知?我想使用相同的按钮删除或取消特定通知.如果是这样,请帮我提供一个示例快速代码.

@IBAction func setNotification(sender: UIButton!) {

        cell = tableView.cellForRowAtIndexPath(NSIndexPath(forRow: sender.tag, inSection: 0)) as! CustomTableViewCell
        if sender.selected {

            sender.selected = false
             }else {
currentRegion = CLCircularRegion(center: CLLocationCoordinate2D(latitude: latitude ,longitude:longitude), radius: radius, identifier: identifier)
regionMonitor()
            manager.stopUpdatingLocation()
            sender.selected = true } }
Run Code Online (Sandbox Code Playgroud)

代码 didEnterRegion()

func locationManager(manager: CLLocationManager!, didEnterRegion region: CLRegion!) {
            localNotification.regionTriggersOnce = true
            localNotification.alertBody = "you have reached"
            UIApplication.sharedApplication().scheduleLocalNotification(localNotification)
            NSLog("Entering region") }
Run Code Online (Sandbox Code Playgroud)

iphone uitableview ios uilocalnotification swift

3
推荐指数
1
解决办法
1822
查看次数

未定义不是对象(评估'_react.PropTypes.object')

刚刚使用reac-native-init创建了一个新项目。使用

"react": "16.0.0",
"react-native": "0.51.0",
Run Code Online (Sandbox Code Playgroud)

从xcode运行项目我遇到以下错误

未处理的JS异常:模块AppRegistry不是注册的可调用模块(调用runApplication)

未定义不是对象(评估'_react.PropTypes.object')

在我的项目目录中搜索_react.PropTypes.object。它仅在mobx-react文件夹中使用。现在我的项目无法运行,它停留在启动屏幕上。任何帮助是极大的赞赏

编辑

现在我收到此错误

_react3.default.PropTypes.shape

但是我在整个项目中找不到这条线

javascript react-native mobx-react

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