我的照片扩展程序应用可以访问相机和照片.一切正常,但按完成后,无法保存图像.
标准完成处理程序代码:
- (void)finishContentEditingWithCompletionHandler:(void (^)(PHContentEditingOutput *))completionHandler {
// Update UI to reflect that editing has finished and output is being rendered.
// Render and provide output on a background queue.
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
PHContentEditingOutput *output = [[PHContentEditingOutput alloc] initWithContentEditingInput:self.input];
NSError* error = nil;
NSData *renderedJPEGData = UIImageJPEGRepresentation(filtered_ui_image, 1.0);
assert(renderedJPEGData != nil);
//BOOL written_well = [renderedJPEGData writeToURL:output.renderedContentURL atomically:YES];
BOOL written_well = [renderedJPEGData writeToURL:output.renderedContentURL options:NSDataWritingAtomic error:&error];
assert(written_well);
// Call completion handler to commit edit to Photos.
completionHandler(output);
});
}
Run Code Online (Sandbox Code Playgroud)
renderedJPEGData …
我正在 SwiftUI 中使用 ForEach 制作自定义列表。我的目标是进行滑动删除手势,而不是将 ForEach 嵌入到列表中。
到目前为止,这是我的代码:
import SwiftUI
struct ContentView: View {
let list = ["item1", "item2", "item3", "item4", "item5", "item6"]
var body: some View {
VStack {
List{
ForEach(list, id: \.self) { item in
Text(item)
.foregroundColor(.white)
.frame(maxWidth: .infinity)
.padding()
.background(Color.red)
.cornerRadius(20)
.padding()
}
}
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Run Code Online (Sandbox Code Playgroud)
我似乎找不到一种手势可以让我在不使用列表视图的情况下进行滑动删除。
我还想制作一个自定义删除按钮,当用户向左滑动项目时显示该按钮(如下图所示)。
我有这样的功能:
void findScarf1(bool ** matrix, int m, int n, int radius, int connectivity);
Run Code Online (Sandbox Code Playgroud)
在main函数中我创建了2d动态数组来传递这个函数
bool matrix[6][7] = {
{0, 0, 1, 1, 1, 0, 0},
{0, 0, 1, 1, 1, 0, 0},
{0, 0, 1, 1, 1, 0, 0},
{0, 0, 1, 1, 1, 0, 0},
{0, 0, 1, 1, 1, 0, 0},
{0, 0, 1, 1, 1, 0, 0}
};
Run Code Online (Sandbox Code Playgroud)
问题是:
findScarf1(matrix, 6, 7, 3, 4);
Run Code Online (Sandbox Code Playgroud)
导致 错误C2664:'findScarf1':无法将参数1从'bool [6] [7]'转换为'bool**'
如何紧凑地初始化数组(同时声明)?
抱歉,如果这是重复的问题,但我花了1.5个小时搞清楚
我必须调试python项目.PyCharm IDE似乎很好(我下载了Community Edition,因为它是免费的).
但主要脚本是从Docker"调用"的(我对它不太熟悉).我发现的所有资源都说可以将Docker添加为远程解释器.
PyCharm CE有局限性,因此无法在此IDE中添加"远程解释器".
你知道一些解决方法吗?
也许PyCharm可以连接到"某些东西"(一些非官方项目),而"某些东西"使用Docker?
或者也许还有另一个有这种可能性的好IDE?(我不想在命令行中调试).
提前致谢.
请注意,我正在寻找/Applications/Xcode.app/Contents/Developer/usr/bin/instruments
util(小写),而不是Instruments
可以在 中找到的应用程序Xcode.app/Contents/Applications
。
我的电脑上有 和Xcode12
。Xcode13-beta-5
\n运行时xcrun instruments -w <device id>
,Xcode13 显示xcrun: error: Failed to locate 'instruments'
。
在 Xcode12 中找到“instruments”:
\nolia@Olhas-MacBook-Pro % ls /Applications/Xcode.app/Contents/Developer/usr/bin/*instruments* \n\n# output \xe2\x9c\x85\n/Applications/Xcode.app/Contents/Developer/usr/bin/instruments\n
Run Code Online (Sandbox Code Playgroud)\n在 Xcode13 中找到“instruments”:
\nolia@Olhas-MacBook-Pro % ls /Applications/Xcode-beta.app/Contents/Developer/usr/bin/*instruments* \n\n# output \xe2\x9d\x8c \nzsh: no matches found: /Applications/Xcode-beta.app/Contents/Developer/usr/bin/*instruments* \n
Run Code Online (Sandbox Code Playgroud)\n这里,Xcode-beta.app
是Xcode13,Xcode.app
是Xcode12。
我正在与CGContextDrawImage
/CGDataProviderCopyData
函数中的内部缓存(15 mp 图像大约 90 MB)作斗争。
这是分析器中的堆栈跟踪:
在所有情况下,IOSurface
都是作为“缓存”创建的,并且在@autoreleasepool
排空后不会被清除。
这给应用程序留下了极少的生存机会。
缓存并不取决于图像大小:我试图呈现512x512
,以及4500x512
和4500x2500
(全尺寸)图像块。
在清理它们之前@autoreleasepool
,我使用,CFGetRetainCount
返回1
所有CG
对象。
操作数据的代码:
+ (void)render11:(CIImage*)ciImage fromRect:(CGRect)roi toBitmap:(unsigned char*)bitmap {
@autoreleasepool
{
int w = CGRectGetWidth(roi), h = CGRectGetHeight(roi);
CIContext* ciContext = [CIContext contextWithOptions:nil];
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef cgContext = CGBitmapContextCreate(bitmap, w, h,
8, w*4, colorSpace,
kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);
CGImageRef cgImage = [ciContext createCGImage:ciImage
fromRect:roi
format:kCIFormatRGBA8
colorSpace:colorSpace
deferred:YES];
CGContextDrawImage(cgContext, CGRectMake(0, …
Run Code Online (Sandbox Code Playgroud) 我的 Objc/C++ 项目编译时间太长。即使 Xcode 进行增量构建,也可能需要 140 秒 = 2.5 分钟。
问题是,2.5 分钟的增量构建告诉我没有什么可以改进的。例如Xcode Report Navigator
显示一些文件被编译在4.2s
:
如何检查此文件是否可以编译2.1s
?0.3s
? 除了生成的二进制文件中的符号数量外,还有哪些限制?
我听说应该使用模块来加速增量构建,但让我们假设我正在尝试加快已提取模块的编译时间。
我听说有某种“符号依赖图”,但还没有找到任何实用的建议如何使用它来解决编译时问题。
我已经尝试过这样的工具来发现“符号依赖关系”,但它们似乎太高级了(第一个生成的文件太大而无法graphviz
在 MacOS上打开):
我也见过这样的 Swift 构建标志:-warn-long-function-bodies=200
/ -warn-long-expression-type-checking=200
。这些标志可以标记长函数,但它们能解释为什么这些函数这么长吗?例如,也许有些for loop
写得不好,编译器必须对其进行优化以加快执行速度。在这种情况下,如果程序员以更优化的方式编写该循环,编译器就不必对其进行优化,并且程序员不会在每次构建时等待 1-2 秒。
所以,假设有一个在 N 秒内编译的 Objc/C++ 文件。问题是:
preprocessing a whole file
:N/4 秒,compile func1
:N/4 秒,compile func2
:N/4 秒,optimize an assembly
:N/4 秒。clang
这种东西的实用程序?#include
/#import
这会减慢编译速度。ios ×3
c++ ×2
xcode ×2
caching ×1
clang ×1
compilation ×1
core-image ×1
docker ×1
file-io ×1
iosurface ×1
objective-c ×1
pycharm ×1
python-3.x ×1
swift ×1
swiftui ×1