当我尝试获取特定大小的图像时,PHImageManager.default().requestImage 会使用不同大小的图像调用两次。
这是代码:
static func load(from asset: PHAsset, targetSize: CGSize? = nil, completion: @escaping (UIImage?)->()) {
let options = PHImageRequestOptions()
options.isSynchronous = false
let id = UUID()
PHImageManager.default().requestImage(for: asset, targetSize: targetSize ?? PHImageManagerMaximumSize, contentMode: .aspectFill,
options: options, resultHandler: { image, _ in
print(id)
runInMain {
completion(image)
}
})
}
Run Code Online (Sandbox Code Playgroud)
我添加了 UUID 来检查相同的 UUID 是否打印了两次。
我想绘制一个简单的三角形,但在我尝试创建MTLBuffer.
static float vertexes[] = {
0.0, 0.5, 0.0,
-0.5f, -0.5f, 0.0,
0.5, -0.5f, 0.0
};
id <MTLBuffer> buffer = [self.device newBufferWithBytes:vertexes
length:sizeof(vertexes) options:MTLResourceStorageModePrivate];
Run Code Online (Sandbox Code Playgroud)
这是断言:
-[MTLDebugDevice newBufferWithBytes:length:options:]:392: failed assertion `storageModePrivate incompatible with ...WithBytes variant of newBuffer'
Run Code Online (Sandbox Code Playgroud)
那么如何使用 MTLResourceStorageModePrivate 选项从顶点创建缓冲区?
我想在 ActionBar 中创建一个带有文本和图标的按钮。类似于下面的屏幕截图。

我试过这个代码。但它不起作用。它只显示没有文字的图标。
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/create"
android:title="@string/create"
android:icon="@drawable/ic_apply"
android:showAsAction="always|withText" />
</menu>
Run Code Online (Sandbox Code Playgroud) 这是我的代码:
onView(withId(R.id.first_name)).perform(
typeText("John"), closeSoftKeyboard());
SystemClock.sleep(5000);
onView(withId(R.id.last_name)).perform(typeText("Smith"));
Run Code Online (Sandbox Code Playgroud)
我从这里尝试了答案 Android:java.lang.SecurityException:注入到另一个应用程序需要INJECT_EVENTS权限 ,但没有帮助。
这是我使用的Expresso版本:
// Android Test Support Libraries
espressoRunnerVersion = "0.5"
espressoRulesVersion = "0.5"
espressoVersion = "2.2.2"
Run Code Online (Sandbox Code Playgroud)
这是完整的堆栈跟踪:
android.support.test.espresso.PerformException: Error performing 'type text(Smith)' on view 'with id: church.life.app:id/last_name'.
at android.support.test.espresso.PerformException$Builder.build(PerformException.java:84)
at android.support.test.espresso.base.DefaultFailureHandler.getUserFriendlyError(DefaultFailureHandler.java:81)
at android.support.test.espresso.base.DefaultFailureHandler.handle(DefaultFailureHandler.java:52)
at android.support.test.espresso.ViewInteraction.waitForAndHandleInteractionResults(ViewInteraction.java:312)
at android.support.test.espresso.ViewInteraction.desugaredPerform(ViewInteraction.java:167)
at android.support.test.espresso.ViewInteraction.perform(ViewInteraction.java:110)
at church.life.app.ui.profile.ProfileSignupTest.InvalidSignupTest(ProfileSignupTest.java:44)
at java.lang.reflect.Method.invoke(Native Method)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at android.support.test.rule.ActivityTestRule$ActivityStatement.evaluate(ActivityTestRule.java:433)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) …Run Code Online (Sandbox Code Playgroud)