我坚持使用适用于iOS的GoogleMaps SDK ...
我想在Google地图上点击GMSMarker时添加一些功能,但它不起作用.有什么不对?
FirstController.h
#import <UIKit/UIKit.h>
#import <GoogleMaps/GoogleMaps.h>
#import <CoreLocation/CoreLocation.h>
#import "sqlite3.h"
@interface FirstViewController : UIViewController <CLLocationManagerDelegate,
GMSMapViewDelegate>
{
sqlite3 *db;
}
Run Code Online (Sandbox Code Playgroud)
FirstController.m
[...]
-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
camera = [GMSCameraPosition cameraWithLatitude:newLocation.coordinate.latitude longitude:newLocation.coordinate.longitude zoom:(12)];
mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
mapView_.myLocationEnabled = YES;
for(GMSMarker *currentMarker in _locationMarkers)
{
currentMarker.map = mapView_;
}
self.view = mapView_;
}
-(BOOL) mapView:(GMSMapView *) mapView didTapMarker:(GMSMarker *)marker
{
NSLog(@"try");
return YES;
}
Run Code Online (Sandbox Code Playgroud) 我使用file()函数将.php文件转换为数组.
现在我修改了数组,我想将所有内容放回文件中(保持行结尾)...
有人可以告诉我是否有一个与file()相反的函数?
我想绕过恼人的"数组到字符串转换"的方式......
提前致谢!
我试过很多方法将我的sqlite db文件复制到我的/ data/data/packagename/databases文件夹,但是我仍然陷入FileNotFoundException,由FileOutputStream对象触发...这是代码:
public static boolean checkCopyDb(Context c, DbHandler _db) {
try {
String destPath = "/data/data/" + c.getPackageName() + "/databases/db_sociallibraries.db";
File dbFile = new File(destPath);
if(!dbFile.exists()) {
_db.copyDb(c.getAssets().open(DB_NAME), new FileOutputStream(destPath)); // Line 44 - Throws the exception
}
return true;
}
catch (IOException e) {
e.printStackTrace();
return false;
}
}
private void copyDb(InputStream inputStream, OutputStream outputStream) throws IOException {
byte[] buffer = new byte[1024];
int length;
while((length = inputStream.read(buffer)) > 0) {
outputStream.write(buffer,0,length);
}
inputStream.close();
outputStream.close();
}
Run Code Online (Sandbox Code Playgroud)
这是错误:
02-09 …
sqlite android assets filenotfoundexception fileoutputstream