Spa*_*Dog 1 ios scenekit scnnode scntext
我正在阅读陀螺仪并将SCNText几何形状的弦更改为陀螺仪的偏航值.这种变化发生在陀螺仪处理器内部,每1/30秒调用一次.在SCNText几何与Interface Builder中创建.
我正在使用此代码来检索对文本的引用:
SCNNode *textNode = [scene.rootNode childNodeWithName:@"yawText" recursively:YES];
self.text = [textNode geometry];
//self.txt is declared as @property (strong, nonatomic) SCNText *text;
Run Code Online (Sandbox Code Playgroud)
稍后在陀螺仪手柄上我这样做:
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;
Run Code Online (Sandbox Code Playgroud)
NSLog正确打印值但是没有变化SCNText.
是的,我试图更改主线程上的文本.没变.
string在SCNText几何体上设置就足够了.
textNode.geometry.string = "0.5"
Run Code Online (Sandbox Code Playgroud)
如果您没有看到任何更改,那么weakSelfText不会指向您认为它的位置.确保你没有丢弃某处的引用:
NSAssert(weakSelfText == textNode.geometry, @"pointers not the same")
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
884 次 |
| 最近记录: |