小编Gra*_*son的帖子

NSView或NSWindow中的孔

是否可以删除NSWindow或NSView的部分内容并让它们通过?我有一个带有NSView的NSWindow,我想要:

A)在NSWindow打个洞,以便能够透过它看到

B)设置我的NSWindow背景以获得清晰的颜色,然后在顶部创建一个NSView并设置我的NSViews不透明度的某一部分,以便能够看到桌面.

这是我想要创建的效果:

在此输入图像描述

xcode cocoa objective-c

13
推荐指数
1
解决办法
1637
查看次数

以编程方式更改NSSlider值

有没有办法制作NSSlider的IBOutlet,然后能够以编程方式更改其值?slider.value =......不起作用.

谢谢!

macos xcode cocoa objective-c nsslider

10
推荐指数
2
解决办法
7861
查看次数

iSight环境传感器

我意识到没有关于isight光传感器使用的任何公开文档,但是像ShadowBook这样的程序(如此处所示)能够访问亮度数据,我只是想知道是否有人能够获得类似的结果和知道如何访问这个传感器?谢谢!

macos xcode cocoa isight objective-c

6
推荐指数
1
解决办法
1236
查看次数

在NSView上使用NSPoint鼠标跟踪

我在App Delegate中有这个方法,它创建了一个窗口和内容视图,但我希望能够在输入和退出视图时使用NSPoint跟踪鼠标.问题是我不想创建一个NSView Custom类,并希望在我的AppDelegate中完成所有操作.鼠标跟踪(在底部)不起作用,有什么建议吗?

- (void)toggleHelpDisplay
{
        // Create helpWindow.
        NSRect mainFrame = [[NSScreen mainScreen] frame];
        NSRect helpFrame = NSZeroRect;
        float width = 75;
        float height = 75;
        helpFrame.origin.x = (mainFrame.size.width - width) / 2.0;
        helpFrame.origin.y = 200.0;
        helpFrame.size.width = width;
        helpFrame.size.height = height;
        helpWindow = [[BrightnessView windowWithFrame:helpFrame] retain];

        // Configure window.
        [helpWindow setReleasedWhenClosed:YES];
        [helpWindow setHidesOnDeactivate:NO];
        [helpWindow setCanHide:NO];
        [helpWindow setCollectionBehavior:NSWindowCollectionBehaviorCanJoinAllSpaces];
        [helpWindow setIgnoresMouseEvents:NO];

        // Configure contentView.
        NSView *contentView = [helpWindow contentView];
        [contentView setWantsLayer:YES];
        CATextLayer *layer = [CATextLayer layer];
        layer.opacity = 0;
        [contentView …
Run Code Online (Sandbox Code Playgroud)

xcode cocoa objective-c

4
推荐指数
1
解决办法
1960
查看次数

以编程方式创建NSPopUpButton

如何以NSPopUpButton编程方式创建并将菜单项附加到其中?这是我到目前为止,但它不是点击能力,也没有附加任何菜单项

帮助窗口只是我的名字 NSWindow

NSPopUpButton *button = [[NSPopUpButton alloc] initWithFrame:NSMakeRect(10, 0, 50, 50)];
[[helpWindow contentView] addSubview:button];
[button setNeedsDisplay:YES]; 
Run Code Online (Sandbox Code Playgroud)

xcode cocoa objective-c nspopupbutton

4
推荐指数
2
解决办法
4359
查看次数

使用NSTimer的秒表错误地包括显示中的暂停时间

这是我的iPhone秒表代码.它按预期工作,并在单击按钮时停止并恢复.

然而,当我点击"停止"时,计时器将不会在后台停止运行,当我点击"开始"恢复它时,它将更新时间并跳到当前的位置,而不是从停止的时间恢复.

我怎么能阻止NSTimer?是什么导致这种情况发生?

@implementation FirstViewController;
@synthesize stopWatchLabel;

NSDate *startDate;
NSTimer *stopWatchTimer;
int touchCount;


-(void)showActivity {

    NSDate *currentDate = [NSDate date];
    NSTimeInterval timeInterval = [currentDate timeIntervalSinceDate:startDate];
    NSDate *timerDate = [NSDate dateWithTimeIntervalSince1970:timeInterval];
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"mm:ss.SS"];
    [dateFormatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0.0]];
    NSString *timeString=[dateFormatter stringFromDate:timerDate];
    stopWatchLabel.text = timeString;
    [dateFormatter release];
}

- (IBAction)onStartPressed:(id)sender {

    stopWatchTimer = [NSTimer scheduledTimerWithTimeInterval:1/10 target:self selector:@selector(showActivity) userInfo:nil repeats:YES];

    touchCount += 1;
    if (touchCount > 1)
    {
        [stopWatchTimer fire];
    }
    else 
    {
        startDate = [[NSDate date]retain]; …
Run Code Online (Sandbox Code Playgroud)

time cocoa-touch objective-c nstimer ios

3
推荐指数
1
解决办法
5583
查看次数

检测按住鼠标

我试图能够检测到何时按住鼠标而不是单击鼠标.这就是我所拥有的,但我希望能够检测到被按住的鼠标,而不是点击次数.

-(void)mouseDown:(NSEvent *)event;
{
    //instead of clickCount I want my if statement to be 
    // if the mouse is being held down.
    if ([event clickCount] < 1) 
    {

    }
    else if ([event clickCount] > 1)
    {

    }
}
Run Code Online (Sandbox Code Playgroud)

cocoa objective-c event-handling

3
推荐指数
2
解决办法
2908
查看次数

设置PopUpButton的操作

我已经以编程方式创建了一个NSPopUpButton,并为我的选择创建了一个数组,如何为每个单独的数组选择创建一个setAction?谢谢!

NSRect buttonRect = NSMakeRect(1705, 145, 78, 50); 

    //Button Array.  When I pick the choice it closes the diologue box
    NSArray *newArray;
    NSString *color1 = @"Blue Color";
    NSString *color2 = @"Green Color";
    NSString *color3 = @"Clear Color";

    newArray = [NSArray arrayWithObjects: color1, color2, color3, nil];

    NSPopUpButton *button = [[NSPopUpButton alloc] initWithFrame:buttonRect pullsDown:YES];
    [self addSubview:button];
    [button addItemsWithTitles:newArray];
    //want my action for each individual string
    [button setAction:@selector(changeFilterColor)];

-(void) changeFilterColor
{
    NSLog(@"colorChanged");

}
Run Code Online (Sandbox Code Playgroud)

xcode cocoa objective-c nspopupbutton

2
推荐指数
1
解决办法
4312
查看次数

响应本机上传到 YouTube

我正在尝试上传我使用 react native 相机在本地拍摄的视频,然后将其发送到 youtube 进行处理,然后想在 react.js 网络仪表板上显示该视频。

我们尝试使用 fetch-blob 上传视频,并使用 cloud firestore 存储视频。我们不确定如何上传到 youtube。我知道有上传文档,但是我们可以直接从我们的 react-native 项目直接上传到 youtube,还是必须上传到诸如 firebase 之类的数据库,然后使用云功能将其发送到 youtube?有没有人尝试过这个?另一种选择是我们可以上传到 S3,然后使用 AWS cloudstream 进行播放,但如果我们可以使用简单的 youtube 上传,这似乎有点过分。我们是否必须先向 youtube 验证用户,然后才能使用?我们不希望任何人都必须登录 Google 帐户。我们只是希望有一个使用 youtube 创建的应用程序,我们可以将其上传到我们的频道。

谢谢!

youtube video file-upload reactjs react-native

2
推荐指数
1
解决办法
1489
查看次数

检测首次用户

如何检测用户是否刚刚下载了应用程序并首次打开它?这是NSUserDefaults吗?我希望能够在我的应用程序第一次运行时显示欢迎屏幕.

谢谢

xcode cocoa objective-c

1
推荐指数
1
解决办法
1480
查看次数