小编zrz*_*zka的帖子

声明一个不会在Scala中返回的函数

是否可以在Scala中声明“不返回”功能?即

def abort(): ! = {
    System.exit(1);
}
Run Code Online (Sandbox Code Playgroud)

!本例中的取自Rust,这意味着:进入此函数是单程旅行,我们将永远不会从中返回)

scala

14
推荐指数
2
解决办法
449
查看次数

Xcode 5工具栏按钮不起作用

我在安装Xcode 5后出现问题.显示/隐藏Assistant Editor和Version Editor的工具栏按钮不起作用.他们根本没有回应; 我必须从菜单中访问这些功能.

此外,显示/隐藏导航,调试和实用程序窗格的按钮不起作用.工具提示有效,他们只是不响应点击.

还有谁有相同的问题吗?

我得到OS X 10.8.5和XCode 5.0.我从Xcode 4.6升级,我从未安装任何测试版.

xcode toolbars

13
推荐指数
2
解决办法
3130
查看次数

MPMoviewPlayerController全屏播放旋转,底层UIViewController仅限纵向模式(不允许旋转)

你好,

我有一个简单的应用程序,它包含带有两个UIViewControllers的UITabBarController.两个UIViewControllers都只是纵向(不允许旋转).一个UIViewController的UIView确实包含MPMoviePlayerController的视图,允许在该视图中播放视频,并可通过控件(MPMovieControlStyleEmbedded)使其全屏显示.代码很简单,看起来像......

__moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:@"MOVIE_URL"]];
__moviePlayer.controlStyle = MPMovieControlStyleEmbedded;
__moviePlayer.view.frame = CGRectMake( 10, 10, 300, 200 );
__moviePlayer.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
__moviePlayer.shouldAutoplay = NO;
[__moviePlayer prepareToPlay];  
[self.view addSubview:__moviePlayer.view];
Run Code Online (Sandbox Code Playgroud)

...这确实很有效,除非用户切换到全屏播放,我希望允许旋转以允许横向播放.旋转不起作用,因为UITabBarController不允许它(以及两个UIViewControllers).

所以,我尝试了两种方法,但它们都没有按预期工作.

1)Subclassed UITabBarController

我添加了属性BOOL __allowRotation,如果设置为YES,我在UITabBarController的shouldAutorotateToInterfaceOrientation方法中返回YES.

我正在侦听MPMoviePlayerDidEnterFullscreenNotification和MPMoviePlayerWillExitFullscreenNotification通知,将此属性设置为YES和NO.

它确实有效,但问题是,当用户以横向结束视频播放时,底层视图不会旋转回纵向.旋转回纵向的唯一方法是使用私有API,这不是没有.

2)视图/层转换

我也尝试过监听MPMoviePlayerDidEnterFullscreenNotification和MPMoviePlayerWillExitFullscreenNotification通知.

当我收到MPMoviePlayerDidEnterFullscreenNotification时,我正在启动UIDevice方向通知以获取设备方向.我正在尝试根据当前的设备方向转换MPMoviePlayerController的视图层,但它有点免疫,因为它什么都不做.我可以分配任何转换属性,但它什么都不做.

它没有做任何不太正确的事情.当我在旋转期间应用变换时,当我从全屏切换回嵌入式视频播放时,我可以看到此变换的效果.

3)单独的UIWindow

我还没有测试过这个,但我发现MPMoviePlayerController创建单独的UIWindow用于全屏播放,应该可以通过[[UIApplication sharedApplication] windows]访问.这解释了为什么在全屏播放期间不应用转换.

但是我非常不喜欢这个解决方案,因为UIWindow无法识别,我不想使用像objectAtIndex:1这样的魔术常量,或者将转换应用到除主要部分之外的所有UIWindows等.

除了可以修改底层实现并且它将停止工作的事实.

所以,问题是,当底层UIView(即UIView的UIViewController)禁止旋转并仅允许纵向时,如何允许MPMoviePlayerController全屏播放仅旋转?

iphone cocoa-touch rotation mpmovieplayercontroller uitabbarcontroller

12
推荐指数
2
解决办法
2万
查看次数

查找字符串中字符的索引

我有一个字符串NSString *Original=@"88) 12-sep-2012";Original=@"8) blablabla";

我想只打印")"之前的字符,以便如何找到字符")"的索引.或者我怎么能这样做?

提前致谢.

iphone objective-c nsstring ios

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

NSTableView 在第一行上方有不需要的空间

我有一个 NSTableView,它的第一行从顶部向下推 10 pt。标题被关闭,没有组行,单元格间距为 0,封闭滚动视图的内容插入为 0。


更新

这是一个演示该问题的示例项目


这是视图层次结构调试器的抓图:

在此处输入图片说明

这是NSTableRowView在视图层次结构调试器中暂停时第一行的垂直约束:

在此处输入图片说明

我尝试实现委托的tableView(_:didAdd:forRow:)并检查约束,首先使用约束AffectingLayout (for:)

[<NSLayoutConstraint:0x60000390bd40 'NSTableRowView_Encapsulated_Layout_Height' NSTableRowView:0x7fdb12e26eb0.height == 24 priority:500   (active)>]
Run Code Online (Sandbox Code Playgroud)

然后打印所有行视图的约束

  - 0 : <NSLayoutConstraint:0x60000390bcf0 'NSTableRowView_Encapsulated_Layout_Width' NSTableRowView:0x7fdb12e26eb0.width == 329 priority:500   (active)>
  - 1 : <NSLayoutConstraint:0x60000390bd40 'NSTableRowView_Encapsulated_Layout_Height' NSTableRowView:0x7fdb12e26eb0.height == 24 priority:500   (active)>
  - 2 : <NSAutoresizingMaskLayoutConstraint:0x60000390bbb0 h=--& v=-&- InlineCell.minX == 16   (active, names: InlineCell:0x7fdb12e283a0, '|':NSTableRowView:0x7fdb12e26eb0 )>
  - 3 : <NSAutoresizingMaskLayoutConstraint:0x60000390bc00 h=--& v=-&- InlineCell.width == 297   (active, names: InlineCell:0x7fdb12e283a0 )>
  - 4 …
Run Code Online (Sandbox Code Playgroud)

macos nstableview appkit macos-big-sur

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

NSWindow - 无边框,透明窗口 - 动画窗口高度时闪烁的阴影

这是另一个NSWindow问题......我有无边框窗口,透明,这是以这种方式创建的......

- (id)initWithView:(NSView *)view anchorPoint:(NSPoint)anchorPoint position:(NSPoint)position distance:(CGFloat)distance {
  if ( !view ) {
    return nil;
  }

  NSSize size = view.intrinsicContentSize;
  NSRect contentRect = NSMakeRect( 0, 0, size.width, size.height );

  self = [super initWithContentRect:contentRect
                          styleMask:NSBorderlessWindowMask
                            backing:NSBackingStoreBuffered
                              defer:NO];

  if ( !self ) {
    return nil;
  }

  _windowView = view;
  _anchorPoint = anchorPoint;
  _position = position;
  _distance = distance;

  [self setContentView:_windowView];

  [self setExcludedFromWindowsMenu:YES];
  [self setMovableByWindowBackground:NO];

  [self setOpaque:NO];
  [self setBackgroundColor:[NSColor clearColor]];

  [self setHasShadow:YES];
  [self useOptimizedDrawing:YES];

  [self setReleasedWhenClosed:NO];

  [self setFrame:[self windowRectWithSize:contentRect.size] display:YES];

  [self …
Run Code Online (Sandbox Code Playgroud)

cocoa objective-c nswindow

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

如何知道 WKContentRuleList 阻止了什么

众所周知,我们可以使用 WKContentRuleList 来阻止 url 请求/cookie 或在 WKWebView 中执行其他操作。有什么方法可以根据 WKContentRuleList 知道 WKWebView 阻止了哪些内容吗?

ios wkwebview safari-content-blocker

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

无法在 Windows 10 上成功安装 Rust

我正在尝试安装因以下错误而失败的 rust:之前在 Windows 10 上有人遇到过同样的问题吗?任何帮助表示赞赏!

info: syncing channel updates for 'stable-x86_64-pc-windows-msvc'
info: latest update on 2019-02-28, rust version 1.33.0 (2aa4c46cf 2019-02-28)
info: downloading component 'rustc'
info: downloading component 'rust-std'
info: downloading component 'cargo'
info: downloading component 'rust-docs'
info: installing component 'rustc'
57.7 MiB /  57.7 MiB (100 %)   2.6 MiB/s ETA:   0 s
info: installing component 'rust-std'
51.4 MiB /  51.4 MiB (100 %)   4.9 MiB/s ETA:   0 s
info: installing component 'cargo'
  2.8 MiB /   2.8 MiB (100 %) …
Run Code Online (Sandbox Code Playgroud)

windows installation rust

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

比较两个 UIColors(在 UIImageView 中点击位置与资产目录颜色)

我需要点击一个UIImageView...

热点

...并将点击位置的颜色与从资产目录返回的颜色(或在代码中创建的自定义颜色)进行比较。

我在色彩空间方面遇到了很多麻烦,我的比赛总是没有。我已经阅读了一些关于 stackoverflow 的很棒的例子并尝试了它们,但我一定还是做错了什么。

我还尝试使用这样的自定义颜色(而不是资产颜色):

+ (UIColor *)themeRed {
    return [UIColor colorWithRed:192.0f/255.0f green:92.0f/255.0f blue:42.0f/255.0f alpha:1];
}
Run Code Online (Sandbox Code Playgroud)

仍然没有匹配项。我的测试匹配代码如下:

-(void)tappedColorView:(UITapGestureRecognizer *)tapRecognizer {
    CGPoint touchPoint = [tapRecognizer locationInView: uiiv_hs];
    //NSLog(@"my color %@", [uiiv_hs colorOfPoint:touchPoint]);

    UIColor *color = [uiiv_hs colorOfPoint:touchPoint];
    NSLog(@"color %@",[uiiv_hs colorOfPoint:touchPoint]);
    UIColor *matchcolor = [UIColor themeRed];
    NSLog(@"mcolor %@",[UIColor themeRed]);

    NSArray *colors = [NSArray arrayWithObjects:[UIColor colorNamed:@"Color01"],[UIColor colorNamed:@"Color02"], nil];

    if ([color matchesColor:matchcolor error:nil]) {
        NSLog(@"1Match!");
    } else {
        NSLog(@"1No Match!");
    }

    if ([color isEqualToColor:[UIColor …
Run Code Online (Sandbox Code Playgroud)

xcode objective-c uicolor cgcolorspace

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

UIPageControl 点边框颜色

我无法在 iOS 14 中设置页面控件点的边框颜色。以下代码适用于 iOS < 14,但不适用于 iOS 14:

for (int i = 0; i < [self.subViews count]; i++) {
    UIView *dot = [self.subViews objectAtIndex:i];
    dot.layer.borderWidth = 1;
    dot.layer.borderColor = [UIColor blueColor].CGColor;
}
Run Code Online (Sandbox Code Playgroud)

UIPageControl 色调颜色清晰。我只想添加边框。在 Obj-C 中需要一个解决方案。

objective-c ios

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

从具有给定索引的字符串中获取subString

我试图从字符串中获取SubString

这是我打电话的方法

-(NSString *)subStringBetweenStrings:(NSString*)str open:(NSString*)open close:(NSString *)close
{
    if ( str == nil || open == nil || close == nil )
        return nil;

    int start = [str rangeOfString:open].location;
    if (start != -1)
    {
        int end = [str rangeOfString:close].location;
        if ( end != -1)
        {
            return [str substringFromIndex:start]; // DONT WANT
        }
    }
    return nil;       
}
Run Code Online (Sandbox Code Playgroud)

我有start point,我有End point.如何从开始和结束索引获取类似返回的subString[ str subStringWithRange:(start, end)];

iphone cocoa-touch objective-c

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