我在互联网上阅读,但找不到合法的答案.当用户点击按钮显示路线时,我需要打开Google地图.必须自动填写开始和目的地.
我怎样才能在Swift中实现这一目标?
如果有人有解决方案,请提供示例代码.开始始终是用户的当前位置.
我正在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) 我在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) 我在表视图中有一个单元格,其中有一个用于安排通知的按钮.是否可以删除或取消该特定单元格的通知而不影响其他单元格安排的通知?我想使用相同的按钮删除或取消特定通知.如果是这样,请帮我提供一个示例快速代码.
@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) 刚刚使用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
但是我在整个项目中找不到这条线
ios ×4
swift ×4
iphone ×3
uitableview ×2
google-maps ×1
ios8 ×1
javascript ×1
mobx-react ×1
react-native ×1