我创建了一个空白项目(iOS)并将其放在我的viewDidLoad中:
NSString *moviePath = [[NSBundle mainBundle] pathForResource:@"Movie" ofType:@"m4v"];
MPMoviePlayerViewController *playerController = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL fileURLWithPath:moviePath]];
[self presentMoviePlayerViewControllerAnimated:playerController];
[playerController.moviePlayer play];
Run Code Online (Sandbox Code Playgroud)
当应用程序启动时,我得到的是一个白色屏幕,其中包含日志中的错误消息:
<Error>: CGContextSaveGState: invalid context 0x0
<Error>: CGContextClipToRect: invalid context 0x0
<Error>: CGContextTranslateCTM: invalid context 0x0
<Error>: CGContextDrawShading: invalid context 0x0
<Error>: CGContextRestoreGState: invalid context 0x0
Warning: Attempt to present <MPMoviePlayerViewController: 0x821e3b0> on <ViewController: 0x863aa40> whose view is not in the window hierarchy!
Run Code Online (Sandbox Code Playgroud)
......以及一系列关于禁用自动播放的内容.我特别不理解视图不属于层次结构的一行,因为它是一个空白的"单视图应用程序"iOS项目,代码在ViewController.m中.它位于视图层次结构中.
我知道电影文件本身不是问题,因为我是从Apple的MPMoviePlayer上的示例代码中得到的.尽管我(看似)尝试了样本中所写的所有内容,但我还是无法让播放器工作.
这是另一个尝试,这次使用MPMoviePlayerController(不是MPMoviePlayerViewController):
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:url];
[player setContentURL:url];
[player setMovieSourceType:MPMovieSourceTypeFile];
[[player view] setFrame:self.view.bounds]; …Run Code Online (Sandbox Code Playgroud) 为什么要使用AFNetworking的异步方法,只需使用GCD即可完成异步调用?
dispatch_async(bgQ, ^{
//NSURLConnection code
dispatch_async(dispatch_get_main_queue(), ^{
//UI code
});
});
Run Code Online (Sandbox Code Playgroud) 这可能已被问过很多次,但我仍然找不到他们为什么需要的信息.我使用DEVELOPER prov配置文件在我的设备上测试应用程序,这是有道理的.
供应门户网站解释了这样的prov配置文件:
A Provisioning Profile is a collection of digital assets that uniquely ties
developers and devices to an authorized iOS Development Team and enables
a device to be used for testing.
Run Code Online (Sandbox Code Playgroud)
通过这种逻辑,它们仅用于测试,例如不用于分发.我们是否需要在AppStore上部署应用程序?
distribution provisioning app-store ios provisioning-profile
因此,在看到Godus的图像时, 我想知道如何生成一个简单的,非交互式的2D图像,它具有不同的高度或不同高度的不同颜色,如下图所示.
我只想在没有房屋,树木物体和单元的情况下为地形生成基本颜色层.我没有考虑创建一个可以解决这个问题的图形引擎,而是一种在屏幕上生成平面图像的简单方法.
问题是双重的:
1,什么样的数据可以用于这种生成?我想也许ASCII艺术很容易创建和修改以快速改变地形,但很难提供高度信息.
2,在准备好数据之后,可以使用哪些现有框架,类,方法或方法来解决生成问题.
Godus:

ASCII艺术(北欧与挪威,#为瑞典,$为芬兰,%为俄罗斯:

(摘自MapBox文档:http://mapbox.com/developers/utfgrid/#map_data_as_ascii_art )
所以我有一个NSString基本上是一个html包含所有常用html元素的字符串.我想要做的具体事情是从所有img标签中剥离它.
该img标签可能会或可能不会有最大宽度,风格或其他属性,所以我不知道它们的长度达阵.他们总是以/>
我怎么能这样做?
编辑:基于nicolasthenoz答案,我想出了一个需要更少代码的解决方案:
NSString *HTMLTagss = @"<img[^>]*>"; //regex to remove img tag
NSString *stringWithoutImage = [htmlString stringByReplacingOccurrencesOfRegex:HTMLTagss withString:@""];
Run Code Online (Sandbox Code Playgroud) 是否有一个插件或其他方式让XCode 5使符号导航器更有用,只显示当前类并使#pragma标记看起来好像我们点击跳转条?
所有这一切的重点在于我们不必单击跳转条,导航器始终显示为右侧面板上的选项卡.
在我看来,左侧面板上的默认符号导航器很弱.
见附图.
编辑:我自己最终创建了插件.您可以从以下网址下载:https://github.com/zolomatok/ZMDocItemInspector
如果您有兴趣编写自己的插件,这里有一个详细的教程帮助您:https://github.com/zolomatok/Creating-an-Xcode-plugin

我在 上使用better-sqlite3Node,但我怀疑我的问题也适用于node-sqlite3。
我基本上有两个与服务器渲染网站相关的简单问题:
我需要显式调用.close()数据库吗?我似乎记得在某处读过,当当前范围(如当前函数)退出时它会自动关闭。如果我从未.close()在 Web 服务器场景中调用并接受大量请求怎么办?
如果您有一堆不同的组件(身份验证、授权、本地化、支付等),并且每个组件可能需要也可能不需要在请求的整个生命周期中访问数据库(这些组件的生命周期非常短暂,除了付款),是不是更好
谢谢
有没有办法在捕获ios设备屏幕时捕获CAEmitterCells(使用CAEmitterLayer生成)?
UIGetScreenImage()有效,但由于它是私有方法,我不允许使用它.
UIGraphicsBeginImageContext似乎不起作用,从结果图像中简单地省略了粒子.
编辑:
这是我目前用于捕获视图的代码.我实际上正在使用aroth在这里提供的代码录制一个30秒长的屏幕视频.它的工作原理是每秒记录25个自身的图像(它的UIView子类)及其子视图(在我们的例子中包括UIView,其层是CAEmitterLayer),并使用AVAssetWriter来组成记录.
这是非常令人满意的,所以我只是将相关的行放在这里:我在XCode中使用ARC工具对代码进行ARC编辑,因此代码可能与内存管理有点不同.
- (CGContextRef) createBitmapContextOfSize:(CGSize) size {
CGContextRef context = NULL;
CGColorSpaceRef colorSpace;
int bitmapByteCount;
int bitmapBytesPerRow;
bitmapBytesPerRow = (size.width * 4);
bitmapByteCount = (bitmapBytesPerRow * size.height);
colorSpace = CGColorSpaceCreateDeviceRGB();
if (bitmapData != NULL) {
free(bitmapData);
}
bitmapData = malloc( bitmapByteCount );
if (bitmapData == NULL) {
fprintf (stderr, "Memory not allocated!");
return NULL;
}
context = CGBitmapContextCreate (bitmapData,
size.width,
size.height,
8, // bits per component
bitmapBytesPerRow,
colorSpace,
kCGImageAlphaNoneSkipFirst);
CGContextSetAllowsAntialiasing(context,NO);
if (context== …Run Code Online (Sandbox Code Playgroud) 因此,MKAnnotation的centerOffset属性似乎不适用于iOS7以处理自定义注释图像...以下是在iOS6(工作)和iOS7(不工作)中拍摄的图像.
你们知道造成这个问题的原因是什么吗?有没有解决这个问题?
并不是因为iOS7中的centerOffset值是不相关的,所以偏移量不会随着值的变化而变化.

编辑:示例代码:
- (void)viewDidLoad
{
[super viewDidLoad];
MapAnnotation *ann = [[MapAnnotation alloc] initWithName:@"Some annotation" latitude:46.910068 longitude:17.881984 tag:1 type:MAP_ANNOTATION_TYPE_REQUEST];
self.mapView.delegate = self;
[self.mapView addAnnotation:ann];
MKCircle *circle = [MKCircle circleWithCenterCoordinate:CLLocationCoordinate2DMake(46.910068, 17.881984) radius:10];
[self.mapView addOverlay:circle];
}
- (MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id<MKOverlay>)overlay {
if ([overlay isKindOfClass:[MKCircle class]]) {
MKCircleView *cv = [[MKCircleView alloc] initWithCircle:overlay];
cv.fillColor = [UIColor colorWithRed:247/255.f green:85/255.f blue:86/255.f alpha:0.2];
cv.lineWidth = 1;
cv.strokeColor = [UIColor colorWithRed:247/255.f green:85/255.f blue:86/255.f alpha:1.0];
return cv;
}
return nil;
}
- (MKAnnotationView *)mapView:(MKMapView *)mapView …Run Code Online (Sandbox Code Playgroud) 可以通过命令行轻松地在模拟器中构建一个项目,如下所示:
1, xcodebuild -project Someproject.xcodeproj -arch i386 -sdk iphonesimulator
2, /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app/Contents/MacOS/iPhone\ Simulator -SimulateApplication PATHTOAPPFILE/Someproject.app/Someproject
但是这样,应用程序没有像Xcode一样构建的文档和库文件夹 /Users/SOMEUSER/Library/Application Support/iPhone Simulator/6.0/Applications/APPID/Someproject.app
Ergo [NSBundle mainbundle]不会按预期工作.
问题:如何告诉xcodebuild应用程序应该在哪里查找其环境文件夹?
(默认情况下,我相信它会搜索/Users/USER/Library/Application Support/iPhone Simulator/IOSVERSION但会出现问题,因为其他内容已经存在一个Library文件夹)
我不介意在模拟器中运行应用程序之前是否必须手动创建文件夹.
ios ×8
objective-c ×5
image ×2
xcode ×2
afnetworking ×1
app-store ×1
avfoundation ×1
dictionary ×1
distribution ×1
graphics ×1
html ×1
ios7 ×1
map ×1
mkannotation ×1
networking ×1
node-sqlite3 ×1
particles ×1
plugins ×1
provisioning ×1
sqlite ×1
symbols ×1
video ×1
xcode5 ×1
xcodebuild ×1