我已经为我的项目添加了一个测试目标,现在我想分开那些不会在app目标上执行的代码部分.让我们说应用程序调用TestMyApp,我希望它是这样的:
-(void)addDevice:(Account*)account{
NSURL *url = [NSURL URLWithString:K_THINKERBELL_SERVER_URL];
AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:url];
SBJsonWriter *jsonWriter = [[SBJsonWriter alloc] init];
NSDictionary *params = @{@"device_id":account.deviceID,
@"token":account.deviceToken ? account.deviceToken : @"fuygciureygfiyuergfyurgfuyergfuyerguy",
@"type":account.deviceName,
@"os_type":@"ios",
@"os_version":account.os,
@"accounts":_accounts};
NSString *js = [jsonWriter stringWithObject:params];
NSMutableURLRequest *request = [httpClient requestWithMethod:@"PUT" path:@"/device" parameters:nil];
NSData *requestData = [NSData dataWithBytes:[js UTF8String] length:[js length]];
[request setHTTPBody:requestData];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
AFHTTPRequestOperation *operation = [httpClient HTTPRequestOperationWithRequest:request
success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSError *error = nil;
NSDictionary *JSON = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingAllowFragments error:&error]; …Run Code Online (Sandbox Code Playgroud) 我NSLocale用来检测我的用户现在所在的国家/地区.当我想检查用户是否在美国境内时
NSLocale *locale = [NSLocale currentLocale];
NSString *countryCode = [locale objectForKey: NSLocaleCountryCode];
if ([countryCode isEqualToString:@"US"]) {
///////
}
Run Code Online (Sandbox Code Playgroud)
这是检查的正确方法吗?
我希望在一切开始之前将我的场景的一部分设置为隐藏,所以让我说我有一些isHidden(我试图找到)属性,我设置为true之前,或在我的场景的第一帧.
在某些时候我想取消隐藏它并触发动画,我知道如何触发动画.我找到隐藏对象的唯一方法是设置它:
SetActive(false);
Run Code Online (Sandbox Code Playgroud)
它确实隐藏了,但是当我试图稍后在脚本中访问它时
GameObject.Find("gameObjectName");
Run Code Online (Sandbox Code Playgroud)
它返回null.那么,GameObject通过脚本隐藏或隐藏的正确方法是什么.这不是一个Mesh没有网格渲染器.
我有2个NSDate对象,第一个被设置为提前一个月,并且seconed设置为今天.我想检查今天是否在(更大)然后是前一个月对象.
我该怎么做?
我UINAvigatoinBar用十六进制颜色设置我的颜色:
self.navigationController.navigationBar.barTintColor = UIColorFromRGB(0x212121);
Run Code Online (Sandbox Code Playgroud)
它运行良好,IOS7但在较低版本中崩溃与以下:
[UINavigationBar setBarTintColor:]: unrecognized selector sent to instance
Run Code Online (Sandbox Code Playgroud)
我该怎么办?
我正在添加MKCircleView用户注释,如下所示:
- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
{
if (!_MapCentered) {
**_circle = [MKCircle circleWithCenterCoordinate:userLocation.coordinate radius:3000];
[_map_view addOverlay:_circle];**
_MapCentered = YES;
}
}
Run Code Online (Sandbox Code Playgroud)
它将触发一次,一旦用户位置跟踪,它运行良好,但你可以看到圆形视图的直径是3000米.所以现在我希望缩放级别适合CircleView这样:
MKCoordinateRegion viewRegion = MKCoordinateRegionMakeWithDistance(mapView.userLocation.coordinate, 0.270, 0.270);
[_map_view setRegion:viewRegion animated:YES];
Run Code Online (Sandbox Code Playgroud)
我已将delta度数更改为其他数字,但没有任何改变.我怎么能管理这个?
我正在使用一个记录音频的库,我可以每次监听一个新的字节数组,如果填充缓冲区,我得到这个回调:
public void onVoiceReceived(byte[] buffer) {
}
Run Code Online (Sandbox Code Playgroud)
现在我想拿缓冲区并将其转换到一个水平,这样我就可以绘制振幅计.我该如何翻译这些数据?我不想创建另一个记录器并使用该read()命令.
这是绘图代码
private void drawCircleView(Canvas canvas, double ampValue) {
// paint a background color
canvas.drawColor(android.R.color.holo_blue_bright);
// paint a rectangular shape that fill the surface.
int border = 0;
RectF r = new RectF(border, border, canvas.getWidth(), canvas.getHeight());
Paint paint = new Paint();
paint.setARGB(255, 100, 0, 0); // paint color GRAY+SEMY TRANSPARENT
canvas.drawRect(r, paint);
/*
* i want to paint to circles, black and white. one of circles will bounce, tile the button …Run Code Online (Sandbox Code Playgroud) 我已经构建了OpenCV框架IOS,我正在OpenCV从头学习,框架编译得很好,当我运行这段代码时:
IplImage *img = cvLoadImage("dpad_off.png");
cvNamedWindow("Example1",CV_WINDOW_NORMAL);
cvShowImage("Example1", img);
cvWaitKey(0);
cvReleaseImage(&img);
cvDestroyWindow("Example1");
Run Code Online (Sandbox Code Playgroud)
应用程序崩溃与此日志:
OpenCV Error: Unspecified error (The function is not implemented.
Rebuild the library with Windows, GTK+ 2.x or Carbon support.
If you are on Ubuntu or Debian, install libgtk2.0-dev andpkg-config,
then re-run cmake or configure script) in cvNamedWindow, file /Volumes/minijHome/Documents/xcode_mini/hillegass/advancedIOS/postCourse/openCV/clean- downloads/openCVgitClone/opencv/modules/highgui/src/window.cpp, line 652
libc++abi.dylib: terminate called throwing an exception
Run Code Online (Sandbox Code Playgroud)
我试图在网上寻找答案,但无法弄清楚为什么会这样.任何的想法 ?