我正在读取陀螺仪,并将SCNText几何的字符串更改为陀螺的偏航值。更改发生在每隔1/30秒调用一次的陀螺处理程序中。SCNText几何是用Interface创建的。
我使用此代码检索对文本的引用:
SCNNode *textNode = [scene.rootNode childNodeWithName:@"yawText" recursively:YES];
self.text = [textNode geometry];
//self.txt is declared as @property (strong, nonatomic) SCNText *text;稍后,在陀螺仪手柄上,我这样做:
CGFloat yaw = convertToDegrees(attitude.yaw);
[weakSelfText setString:[NSString stringWithFormat:@"%.1f", yaw]];
NSLog(@"yaw = %1f", yaw);
// I had to declare weakSelfText outside the gyro handler
// because Xcode was complaining
// weakSelfText is declared like this
// __weak typeof(self.text) weakSelfText = self.text;NSLog正确地打印值,但SCNText上没有任何更改。
是的,我试图更改主线程上的文本。没有变化。
发布于 2016-03-02 04:21:34
在您的string几何上设置SCNText就足够了。
textNode.geometry.string = "0.5"如果您没有看到任何变化,那么weakSelfText就不会指出您认为它会发生什么变化。确保您不会在某个地方删除引用:
NSAssert(weakSelfText == textNode.geometry, @"pointers not the same")https://stackoverflow.com/questions/35733916
复制相似问题