我想在地图上画一个静态圆圈Google Maps.当用户捏住时,地图将放大/缩小.
我需要知道地图半径(与圆圈中包含的区域相关)并相应地更改底部的搜索条.
有人知道如何检索从左边到右边屏幕边缘的距离吗?我没有在Google Maps API文档中找到任何内容.
像这样的东西:

我正在尝试获取存储在Android文件系统中的文件的真实路径(我正在使用模拟器进行测试Android 8.1)
这是我的代码:
final String id = DocumentsContract.getDocumentId(uri);
final Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"), Long.valueOf(id));
return getDataColumn(context, contentUri, null, null);
Run Code Online (Sandbox Code Playgroud)
对于早期版本Android 8.0,变量id包含一个long值,因此下一行按预期工作.
在Android 8变量中id包含这样的路径raw:/storage/emulated/0/Download/my_file.pdf,所以投射Long.valueOf(id))抛出一个'java.lang.NumberFormatException' Exception.
有任何想法吗?谢谢.
我想实现一个名片检测功能,如这个应用程序(https://scanbot.io).相机应该检测到一张名片并自动拍照(只有名片).

我的想法是使用BradLarson's GPUImage库,检测角落(使用Harris角点检测算法),计算获得角落的最大矩形并裁剪矩形内的图像.
这是我的代码:
- (void)setupFilter {
videoCamera = [[GPUImageVideoCamera alloc] initWithSessionPreset:AVCaptureSessionPreset640x480 cameraPosition:AVCaptureDevicePositionBack];
filter = [[GPUImageHarrisCornerDetectionFilter alloc] init];
[(GPUImageHarrisCornerDetectionFilter *)filter setThreshold:0.01f];
[(GPUImageHarrisCornerDetectionFilter *)filter setSensitivity:0.5f];
[(GPUImageHarrisCornerDetectionFilter *)filter setBlurRadiusInPixels:2.0f];
[videoCamera addTarget:filter];
videoCamera.runBenchmark = YES;
GPUImageView *filterview = [[GPUImageView alloc] init];
self.view=filterview;
GPUImageCrosshairGenerator *crosshairGenerator = [[GPUImageCrosshairGenerator alloc] init];
crosshairGenerator.crosshairWidth = 22.0;
[crosshairGenerator forceProcessingAtSize:CGSizeMake(480.0, 640.0)];
[(GPUImageHarrisCornerDetectionFilter *)filter setCornersDetectedBlock:^(GLfloat* cornerArray, NSUInteger cornersDetected, CMTime frameTime) {
[crosshairGenerator renderCrosshairsFromArray:cornerArray count:cornersDetected frameTime:frameTime];
}];
GPUImageAlphaBlendFilter *blendFilter = [[GPUImageAlphaBlendFilter alloc] init];
[blendFilter forceProcessingAtSize:CGSizeMake(480.0, 640.0)];
GPUImageGammaFilter *gammaFilter …Run Code Online (Sandbox Code Playgroud) 我正在使用 Firestore 数据库来存储对象列表。为了检索它们,我使用StreamFirestore 包提供的,如下所示:
class FirestoreApi implements Api {
FirestoreApi._();
static final instance = FirestoreApi._();
@override
Stream<List<Job>> getJobList() {
final path = "users/myUserId/jobs";
final reference = Firestore.instance.collection(path);
final snapshots = reference.snapshots();
return snapshots.map((snapshot) => snapshot.documents.map(
(snapshot) => Job(
id: snapshot.data['uid'],
name: snapshot.data['name']
),
).toList());
}
}
Run Code Online (Sandbox Code Playgroud)
它实现了一个abstract类:
abstract class Api {
Stream<List<Job>> getJobList();
}
Run Code Online (Sandbox Code Playgroud)
在我的 Repository 类中,我这样称呼它:
class Repository {
final FirestoreApi _firestoreApi = FirestoreApi.instance;
Stream<List<job>> getJobList() => _firestoreApi.getJobList();
}
Run Code Online (Sandbox Code Playgroud)
然后在我的 BloC 中,我调用了存储库:
class JobBloc { …Run Code Online (Sandbox Code Playgroud) 我有一个自定义对象ProductCategory.
.h文件:
#import <Foundation/Foundation.h>
@interface ProductCategory : NSObject
@property int productCategoryId;
@property NSString *name;
@property NSArray *children;
@property int parentCategoryId;
- (id)initWithId:(int)productCategoryId name:(NSString*)name;
- (id)initWithId:(int)productCategoryId name:(NSString*)name children:(NSArray*)chidren parentCategoryId:(int)parentCategoryId;
@end
Run Code Online (Sandbox Code Playgroud)
.m文件:
#import "ProductCategory.h"
@implementation ProductCategory
- (id)init {
if((self = [super init])) {
self.parentCategoryId = 0;
}
return self;
}
- (id)initWithId:(int)productCategoryId name:(NSString*)name {
if((self = [super init])) {
self.productCategoryId = productCategoryId;
self.name = name;
self.parentCategoryId = 0;
}
return self;
}
- (id)initWithId:(int)productCategoryId name:(NSString*)name children:(NSArray*)chidren parentCategoryId:(int)parentCategoryId {
if((self …Run Code Online (Sandbox Code Playgroud) 这是我的podFile:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '7.0'
pod 'AFNetworking'
pod 'ODSAccordionView', '0.4.4'
pod 'IQKeyboardManager'
pod 'NYXImagesKit', :git => 'https://github.com/Nyx0uf/NYXImagesKit.git'
pod 'PEPhotoCropEditor'
pod 'CocoaAsyncSocket'
pod 'PKRevealController'
pod 'Haneke', '~> 1.0'
pod 'MBProgressHUD', '~> 0.9.1'
pod 'RadioButton'
Run Code Online (Sandbox Code Playgroud)
Everythig已经很好地工作了很长时间,但是现在,当我更新我的pods(pod update)时,这三个pod被up upted:
AFNetworkingCocoaAsyncSocketIQKeyboardManager在那之后,没有任何作品了.
我得到了600多个duplicate symbols for architecture i386错误,比如这个错误:
duplicate symbol _OBJC_IVAR_$_AFHTTPRequestOperation._responseSerializer in:
/Users/myuser/Library/Developer/Xcode/DerivedData/MyProject-emjexnnjljambodthokzwpwcddhz/Build/Products/Debug-iphonesimulator/libPods-AFNetworking.a(AFHTTPRequestOperation.o)
/Users/myuser/Library/Developer/Xcode/DerivedData/MyProject-emjexnnjljambodthokzwpwcddhz/Build/Products/Debug-iphonesimulator/libAFNetworking.a(AFHTTPRequestOperation.o)
... (661 times the same error but pointing to different duplicated files)
ld: 661 duplicate symbols for architecture i386
clang: error: linker …Run Code Online (Sandbox Code Playgroud) 我有一个嵌套结构,如下所示:
List<Areas>
|-- List<Topics>
| |-- List<Exercises>
Run Code Online (Sandbox Code Playgroud)
这是我的应用程序的工作流程:
API并显示列表AreasArea并转到下一个屏幕API并显示主题列表Topic并转到下一个屏幕API并显示练习列表我开始使用BloC,但我不确定是否应该对每种类型的数据使用一个 Bloc(因此一个 bloc for Areas,另一个 for Topics,另一个 for Exercises)或仅在一个 Bloc 中处理整个结构。
我看到一个问题,其中State包含整个结构,并且每次从 中获取嵌套列表时都需要更新API。也许这会导致内存问题?
另一方面,每种数据类型都有一个 Bloc 将使它们之间的通信变得复杂。
state management如果更有意义的话,我也愿意改用另一种技术。
任何帮助,将不胜感激。
多谢。
我想使用NSUrlSession下载文件列表.
我有一个用于计算成功下载量的变量@property (nonatomic) int downloadsSuccessfulCounter;.在下载文件时我禁用了Download Button.当计数器等于下载列表大小时,我再次启用该按钮并将计数器设置为0.我在方法中执行此操作:
-(void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask didFinishDownloadingToURL:(NSURL *)location {
...
[[NSOperationQueue mainQueue] addOperationWithBlock:^ {
downloadsSuccessfulCounter++;
if(downloadsSuccessfulCounter == self.downloadList.count) {
NSLog(@"All downloads finished");
[self.syncButton setEnabled:YES];
downloadsSuccessfulCounter = 0;
}
}];
Run Code Online (Sandbox Code Playgroud)
}
一切都运行正常,但当我再次打开ViewController时,我得到了消息A background URLSession with identifier com.myApp already exists!.计数器未设置为0,UI元素(UIButtons,UILabels)没有响应.
我想问题是因为NSURLSession仍然是开放的,但我不确定它是如何工作的.
我已经尝试了所有的教程,但其中99%仅用于下载1个文件,不超过1个...任何想法?
这是我的代码:
...
@property (nonatomic, strong) NSURLSession *session;
...
- (void)viewDidLoad {
[super viewDidLoad];
appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
self.downloadList = [[NSMutableArray alloc] init];
NSURLSessionConfiguration *sessionConfiguration = [NSURLSessionConfiguration backgroundSessionConfiguration:@"com.myApp"];
sessionConfiguration.HTTPMaximumConnectionsPerHost …Run Code Online (Sandbox Code Playgroud) 我正在使用CoreImage Framework来检测名片.当我检测到一个矩形(CIDetectorTypeRectangle)时,我使用此方法绘制一个叠加层:
func drawOverlay(image: CIImage, topLeft: CGPoint, topRight: CGPoint, bottomLeft: CGPoint, bottomRight: CGPoint) -> CIImage {
var overlay = CIImage(color: CIColor(red: 0, green: 0, blue: 1.0, alpha: 0.3))
overlay = overlay.imageByCroppingToRect(image.extent())
overlay = overlay.imageByApplyingFilter("CIPerspectiveTransformWithExtent",
withInputParameters: [
"inputExtent": CIVector(CGRect: image.extent()),
"inputTopLeft": CIVector(CGPoint: topLeft),
"inputTopRight": CIVector(CGPoint: topRight),
"inputBottomLeft": CIVector(CGPoint: bottomLeft),
"inputBottomRight": CIVector(CGPoint: bottomRight)
])
return overlay.imageByCompositingOverImage(image)
}
Run Code Online (Sandbox Code Playgroud)
现在我需要自动拍摄所选区域的图片并保存.有谁知道怎么做?谢谢!
我正在ondoInBackground内的方法中执行数据库操作。AsyncTaskAndroid
由于某种原因,UI该操作在 5-6 秒内被阻塞。
这对我来说没有任何意义, 中的操作doInBackground不应该在 中执行UI Thread,对吗?
这是我的代码:
private class CountItems extends AsyncTask<String, Void, Integer> {
private ProgressDialog dialog;
@Override
protected void onPreExecute() {
dialog = new ProgressDialog(context);
dialog.setCancelable(false);
dialog.setMessage(getString(R.string.asynTask_loading));
dialog.show();
}
@Override
protected Integer doInBackground(String... params) {
// This operation takes 5-6 seconds.
return app.databaseSession().getMyObjectDao().count(selectedProject, filter, null, false);
}
@Override
protected void onPostExecute(Integer result) {
counterTextView.setText(String.valueOf(result));
if (dialog.isShowing()) {
dialog.dismiss();
}
}
}
Run Code Online (Sandbox Code Playgroud)
我做了一个测试。如果我将 a 放在方法Thread.sleep()内部 …
ios ×3
android ×2
crop ×2
flutter ×2
background ×1
bloc ×1
blocking ×1
cocoapods ×1
core-image ×1
dart ×1
database ×1
detection ×1
distance ×1
duplicates ×1
fetch ×1
file ×1
filesystems ×1
firebase ×1
google-maps ×1
gpuimage ×1
hierarchical ×1
ios7 ×1
ios8 ×1
iphone ×1
nested ×1
nsurlsession ×1
objective-c ×1
path ×1
stream ×1
swift ×1
ui-thread ×1
updates ×1
xcode ×1