小编Aar*_*ron的帖子

阻止用户与AVPlayerView交互?

我在我的UI中播放视频进行装饰.我隐藏了AV播放器控件,但用户仍然可以控制视频.例如,他们可以使用滑动手势来快进或快退.

这对我来说特别令人惊讶,因为AVPlayerView在它上面有一个叠加视图.

有谁知道如何阻止所有用户与此视频互动?

cocoa avplayer

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

无法调配类方法

我正在为Mail.app制作一个插件.我想要插件为Mail的工具栏添加一个按钮.为此,我决定最好的方法是调用函数在MessageViewer的initialize方法中添加此按钮(MessageViewer是Mail.app的FirstResponder的类).我正在修改的代码似乎工作得很好:

+ (void) initialize
{  
[super initialize];

//  class_setSuperclass([self class], NSClassFromString(@"MVMailBundle"));
//  [ArchiveMailBundle registerBundle];


// Add a couple methods to the MessageViewer class.
Class MessageViewer = NSClassFromString(@"MessageViewer");

// swizzleSuccess should be NO if any of the following three calls fail
BOOL swizzleSuccess = YES;
swizzleSuccess &= [[self class] copyMethod:@selector(_specialValidateMenuItem:) 
                                 fromClass:[self class] 
                                   toClass:MessageViewer];
swizzleSuccess &= [[self class] copyMethod:@selector(unsubscribeSelectedMessages:) 
                                 fromClass:[self class] 
                                   toClass:MessageViewer];
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试做同样的事情时,它不起作用:

//  //Copy the method to the original MessageViewer
swizzleSuccess &= [[self class] copyMethod:@selector(_specialInitMessageViewer:)
                                 fromClass:[self class]
                                   toClass:MessageViewer];  
Run Code Online (Sandbox Code Playgroud)

以下是混合方法:

+ (BOOL)swizzleMethod:(SEL)origSel …
Run Code Online (Sandbox Code Playgroud)

macos objective-c nsbundle

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

OS X故事板:使用"show"segue而不允许显示重复的新窗口?

现在我有一个OS X故事板应用程序,它有一个主窗口,上面有一个按钮,触发另一个视图控制器的"show"segue.现在我已经将segue设置为模态,因为如果我不这样做,用户可以再次单击相同的按钮,最后得到同一窗口的两个副本.

有没有办法让我完成这个,而不必重新构建故事板,将这些视图控制器嵌入一个单独的窗口控制器中(这似乎会破坏故事板提供的灵活性的目的)?

macos cocoa storyboard

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

RSpec:未定义的方法`double'用于#<RSpec :: Core :: ExampleGroup :: Nested_1:0x007fcc2f626d50>

我写了一个简单的测试,如下:

    require 'spec_helper.rb'

describe Channel do
  before(:each) do
    @channel = Channel.new
  end

  it "should get the true view count" do 
    upload_view_count = double('upload view count')
    upload_view_count.should_receive(:upload_num).and_return(16000666)
    @channel.upload_view_counts << upload_view_count
    @channel.save()
    @channel.true_all_time_views.should equal(16000666)
  end

  it "should get the true view count with multiple upload view counts" do
    upload_vc1 = double('uplaod view count 1')
    upload_vc1.should_receive(:created_at).and_return(Time.now())
    upload_vc1.should_receive(:upload_num).and_return(17666)
    upload_vc1.should_receive(:updated_at).and_return(Time.now())

    upload_vc2 = double('upload view count 2')
    upload_vc2.should_receive(:created_at).and_return(Time.now())
    upload_vc2.should_receive(:upload_num).and_return(17777)
    upload_vc2.should_receive(:updated_at).and_return(Time.now())

    @channel.upload_view_counts << upload_vc1
    @channel.upload_view_counts << upload_vc2
    @channel.save()
    @channel.true_all_time_views.should equal(17777)
  end




end
Run Code Online (Sandbox Code Playgroud)

当我尝试运行此测试时,出现以下错误:

失败:

1)频道应该获得真实的视图计数失败/错误:upload_view_count = double('upload …

rspec rspec2

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

标签 统计

cocoa ×2

macos ×2

avplayer ×1

nsbundle ×1

objective-c ×1

rspec ×1

rspec2 ×1

storyboard ×1