我有一个_TableView
项目,我想设置自动刷新,我不希望它滚动刷新,让我们说用户滚动2页,并刷新trigered - >所以我想把刷新的内容放到表的顶部没有插入用户的滚动
假设用户在第18行,现在_dataSource
刷新,所以它取出让我们说4个项目,所以我希望用户留在他的项目上.
实现它的最佳方法是什么?
我最近审查了我一年前发布的一个应用程序。而且我看到现在NSCollectionView
它的内部已经失去了选择功能,例如 SHIFT + Select 现在它表现为 CMD + Select。
(第二个问题:用鼠标拖动时我也没有得到选择矩形。)
显然我想要这个功能回来,使用 shift 会将选择从先前单击的单元格扩展到 shift 单击的单元格。
我做了什么:
//NSCollectionView * _picturesGridView; //is my iVar
//In initialization I have set my _picturesGridView as follows
//Initializations etc are omitted -- (only the selection related code is here)
[_picturesGridView setSelectable:YES];
[_picturesGridView setAllowsMultipleSelection:YES];
Run Code Online (Sandbox Code Playgroud)
问题:是否有一种简单的方法可以恢复此功能?我在文档中没有看到任何相关的内容,并且在互联网上找不到任何解决方案。
子问题:如果没有简单的方法来实现这一点 -> 我应该继续创建自己的FancyPrefix##CollectionViewClass
功能并按照我的意愿重新实现这个功能 - 还是最好跳过现有的NSCollectionView
并强制它按照我的意愿行事?
子注:好吧,如果我发现自己重新实现它,它将是一个轻量级的类,它只会满足我自己的需求——我的意思是我不会模仿整个NSCollectionView
类。
PS 我可以通过单击来选择一个项目我只能使用 CMD+Click 或 SHIFT+Click 来选择多个项目,但后者的行为与我不想要的 CMD+Click 完全一样。
至于鼠标选择矩形 - 我没有覆盖任何鼠标事件。不清楚为什么我没有这个功能。
我正在开发一个OSX应用程序,它的某些功能需要ROOT权限我想出了如何以root身份调试我的应用程序(只需在方案中).
但我希望用户将其作为Root运行,以便他们可以访问其功能.
我怎样才能做到这一点??
我正在使用SpriteKit开发(或至少尝试开发)一个体面的大型实时战术游戏(类似于RTS).
我正在使用GamePlay工具包进行寻路.
最初我使用SKAction
s来移动路径中的精灵,但足够快我意识到这是一个很大的错误.
然后我试着用GKAgent
s 来实现它(这是我现在的状态)我觉得GKAgent
s非常原始而且不成熟他们正在遵循一些奇怪的Newton Law#1让它们永远移动(我想不出任何场景它会很有用 - 也许适用于WWDC的演示)
以及我看到他们有一些Angular速度来执行我根本不需要的旋转,并且无法真正找到如何禁用它...
除了GKBehavior
给定GKGoal
s似乎做出一些奇怪的事情......
设置行为以避开障碍物使我的单位在他们周围慢跑...设置跟随路径目标的行为完全忽略了一切,除非maxPredictionTime
它足够低......我甚至不愿意告诉当我将它们组合时会发生什么.
我觉得很破碎......
我觉得我现在有两个选择:
1)与这些代理人进行更多的斗争,并试图让他们按照我的意愿行事
2)在我的帮助下自行滚动所有的动作GKObstacleGraph
和一条路径Finding(这也是我在某些方面要说的路径,这条路的路径会产生最糟糕的路径,比如"触摸那个障碍然后反向触摸"那个人然后去实际点(从一开始就可以通过直线实现)").
问题是:
这些选项中最好的是什么?
我想在mac OSX应用程序中在我的屏幕上绘制动画gif.我使用这段代码插入gif:我可以看到Gif为1张图片它不会动画只有静态图片:(我应该添加什么才能使其动画?
#import <Cocoa/Cocoa.h>
#import <Quartz/Quartz.h>//for drawing circle
#import "sharedPrefferences.h"
@interface GenericFanSubView : NSView
{
NSColor * _backgroundColor;
NSImageView* imageView;
}
- (void)setBackgroundColor :(NSColor*)color;
- (void)insertGif1;
- (void)insertGif2;
- (void)insertGif3;
@end
#import "GenericFanSubView.h"
#define PI 3.14285714285714
@implementation GenericFanSubView
- (id)initWithFrame:(NSRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code here.
imageView = [[NSImageView alloc]initWithFrame:CGRectMake(0, 0,self.frame.size.width,self.frame.size.height)];
[imageView setAnimates: YES];
}
return self;
}
- (void)drawRect:(NSRect)dirtyRect
{
[super drawRect:dirtyRect];
// Drawing code here.
[self drawCircleInRect];
_backgroundColor = [NSColor whiteColor];
[self …
Run Code Online (Sandbox Code Playgroud) 我希望得到一个当前节点位置形成一个SCNNode
我知道的动画presentationNode
,我试图在那里提取位置形式,但没有运气
这是我的代码
SCNNode * pelvis = [_unit childNodeWithName:@"Bip01_Pelvis" recursively:YES];
SCNNode * present = pelvis.presentationNode;
SCNVector3 position = [self convertPosition:present.position toNode:self.parentNode];
Run Code Online (Sandbox Code Playgroud)
我所拥有的位置是SCNNode
在CAAnimation
应用之前处于"休息"模式的位置.
如何从'presentationNode'获取位置等属性?
编辑
类本身相关部分:
@interface UndeadSimple : RepresentationNode <CAAnimationDelegate>
{
//Animations
SCNNode * _undead;
CAAnimation * _currentAnimation;
NSString * _currAnimationkey;
CAAnimation * _death1;
...
SCNNode * _audioNode;
SCNAudioSource * _deathSource;
SCNAudioPlayer * _player;
}
Run Code Online (Sandbox Code Playgroud)
在里面:
NSString * sceneName = @ZOMBIE;
SCNScene *scene2 = [SCNScene sceneNamed:sceneName];
_undead = [SCNNode node];
for(SCNNode * node …
Run Code Online (Sandbox Code Playgroud) 是否有足够的方法将贴花(纹理)添加到SCNNode
?现在,我所能做的就是SCNNode
用SCNPlane
几何图形创建新对象,为其漫反射内容分配纹理并将其添加到场景中……这种方法效率极低。
我想添加一个不属于场景的贴花-以提高游戏的性能。因为我想在地板节点上放置相对大量的贴花。
也许有点类似于粒子内部的工作原理?或其他一些快速图像绘制方法。
我已经尝试过@rickster的建议1
将SKEffectNode用作SpriteKit场景中的缓冲区—将splatters扔到一个效果节点中,直到它到达一定数量的子代为止,然后打开其shouldRasterize选项,以使其不再重新渲染其子代(并开始使用新的效果节点以获得更多效果)。
在同一个SceneKit showreel项目中-仅此一项就已经取得了不错的效果,FPS在持续播放场景的过程中并没有像连续5分钟那样下降。
期待实施建议2-我相信它将减少2D场景渲染时间(目前这是一个很大的数目)。
在此屏幕快照中,有5k贴花
我使用的是UIImagePickerController
与sourceType = UIImagePickerControllerSourceTypeCamera;
但是我想指定我只想拍摄照片,而不是视频,(在原生相机用户可以切换到视频)有没有办法这样做?
这是我正在使用的代码:
if (([UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypeCamera] == NO))
return ;
UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init];
cameraUI.sourceType = UIImagePickerControllerSourceTypeCamera;
// Displays a control that allows the user to choose picture or
// movie capture, if both are available:
cameraUI.mediaTypes =
[UIImagePickerController availableMediaTypesForSourceType:
UIImagePickerControllerSourceTypeCamera];
// Hides the controls for moving & scaling pictures, or for
// trimming movies. To instead show the controls, use YES.
cameraUI.allowsEditing = NO;
cameraUI.delegate = self;
[self presentViewController:cameraUI animated:YES completion:nil]; …
Run Code Online (Sandbox Code Playgroud) 我想把我的NSView
(带图层)作为图像我可以在OSX中这样做吗?
在iOS中我会做以下
-(UIImage*) makeImage//snapshot the view
{
UIGraphicsBeginImageContext(self.view.bounds.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return viewImage;
}
Run Code Online (Sandbox Code Playgroud)
我从一个SO答案中尝试了这个解决方案
[[NSImage alloc] initWithData:[view dataWithPDFInsideRect:[view bounds]]];
Run Code Online (Sandbox Code Playgroud)
但它不起作用,因为我在我的NSView
.
我从将UI转换为NS开始,现在每行都有警告:)
-(NSImage*) makeImage :(RMBlurredView*)view
{
UIGraphicsBeginImageContext(view.bounds.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
NSImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return viewImage;
}
Run Code Online (Sandbox Code Playgroud)
我不熟悉OSX可以帮助我将这段代码转换成OSX吗?
objective-c ×7
cocoa ×5
macos ×5
ios ×2
scenekit ×2
swift ×2
animated-gif ×1
caanimation ×1
gameplay-kit ×1
ios8 ×1
nsimage ×1
scnnode ×1
sprite-kit ×1
uitableview ×1