小编nar*_*ner的帖子

使用Visual Studio在Mac上创建新的Angular项目

我目前正在https://channel9.msdn.com/Events/Visual-Studio/Visual-Studio-2017-Launch/WEB-103使用Mac上的Visual Studio设置Spa应用程序(macOS Sierra,Visual Studio Community 2017)。

我已经成功安装了角核,目前正在尝试根据已安装的模板之一创建一个新项目。

运行时,我可以看到两个角度模板sudo dotnet new -l

MVC ASP.NET Core with Angular angular [C#] Web/MVC/SPA ASP.NET Core with Angular angular [C#] Web/MVC/SPA

运行时sudo dotnet new angular,我不断收到以下错误:

Unable to determine the desired template from the input template name: angular.
The following templates partially match the input. Be more specific with the template name and/or language.

Templates                          Short Name      Language      Tags       
----------------------------------------------------------------------------
MVC ASP.NET Core with Angular      angular         [C#]          Web/MVC/SPA
ASP.NET Core …
Run Code Online (Sandbox Code Playgroud)

macos visual-studio-community angular

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

在没有预览窗口的情况下使用 AVCaptureVideoDataOutputSampleBufferDelegate

我正在开发一个基于 Swift 的 macOS 应用程序,我需要在其中捕获视频输入,但不将其显示在屏幕上......而不是显示视频,我想将缓冲数据发送到其他地方进行处理,并最终显示它在SceneKit场景中的对象上。

我有一个CameraInputprepareCamera方法的类:

    fileprivate func prepareCamera() {
        self.videoSession = AVCaptureSession()
        self.videoSession.sessionPreset = AVCaptureSession.Preset.photo

        if let devices = AVCaptureDevice.devices() as? [AVCaptureDevice] {
            for device in devices {
                if device.hasMediaType(AVMediaType.video) {
                    cameraDevice = device

                    if cameraDevice != nil  {
                        do {
                            let input = try AVCaptureDeviceInput(device: cameraDevice)


                            if videoSession.canAddInput(input) {
                                videoSession.addInput(input)
                            }


                           } catch {
                            print(error.localizedDescription)
                        }
                    }
                }
            }

            let videoOutput = AVCaptureVideoDataOutput()
            videoOutput.setSampleBufferDelegate(self as AVCaptureVideoDataOutputSampleBufferDelegate, queue: DispatchQueue(label: "sample buffer delegate", attributes: …
Run Code Online (Sandbox Code Playgroud)

macos avfoundation avcapturesession cmsamplebuffer swift

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

Autolayout高度成比例但具有上限约束

UI工作表设计

我正在尝试使用Autolayout和仅使用Interface Builder在所有四个iPhone设备中生成具有2个视图的以下场景.如图所示,我希望视图2(底视图)在iPhone 4上不小于45点,并且永远不会高于65点.如果您对解决方案的想法使用某种比例,则View2不必完全是附加图像中指定的点数.

xcode interface-builder ios autolayout

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

嵌套类中名为`Type`的枚举失败

由于某种原因,具有嵌套枚举的嵌套类名为Typedosen不能很好地与swift编译器一起使用.

class A {

    class B {

        enum Type {
            case One
            case Two
        }

        let myC: Type

        init(myC: Type) {
            self.myC = myC
        }

    }

    func getB(myC: B.Type) -> B {
        return B(myC: myC) // ERROR 1
    }

}

let a = A()
let b = a.getB(.Two) // ERROR 2
Run Code Online (Sandbox Code Playgroud)

上面的代码产生两个错误:'A.B.Type' is not convertible to 'A.B.Type''A.B.Type.Type' does not have a member named 'Two'.

以下案例确实有效:

  • class B 在外面 class A
  • let b = A.B(myC: …

enums swift

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

使用最小高度单元格自动调整表格视图

我有一个针对iOS7/8的项目.在iOS7上我做手动单元高度计算,在iOS8上我让系统进行数学运算.

单元格主要包含两个垂直堆叠的标签,标题和描述,位于两个装饰视图的左侧,不受我的问题的影响.

我试图让所有细胞以60点的高度出现,当它们被点击时,它们不会被截断为全尺寸.这适用于大多数情况.有一个边缘情况,标题和描述实际上不会截断.在这种情况下,在iOS8上点击单元格会缩小它最微小,令人讨厌的一点点.

我想知道是否有办法为表格单元设置最小高度,除了在iOS 8中设置自动调整表的估计行高?

我希望这是有道理的,如果我需要更好地解释,请告诉我.如何为iOS 8自动调整单元格设置最小高度,我们对此表示赞赏.

正常情况 - 截断标题和描述/扩展点击

截断标题/说明 扩展的标题/描述

边缘情况 - 没有任何内容被截断/展开实际上缩小了单元格

什么都没有截断 没有任何截断扩展

我在iOS 8上heightForRowAtIndexPath返回UITableViewAutomaticDimension并在iOS7上使用测量单元计算它.我还将该rowHeight物业硬编码到60.0f我预期的最小高度,与IB中的布局相匹配.

当点击单元格时,我调用一个函数来将单元格设置为展开.我用这些变化制作动画[tableView beginUpdates].

- (void) setIsExpanded:(BOOL)isExpanded {
    _isExpanded = isExpanded;

    if (_isExpanded) {
        [_descriptionText setLineBreakMode:NSLineBreakByWordWrapping];
        [_descriptionText setNumberOfLines:0];

        [_title setLineBreakMode:NSLineBreakByWordWrapping];
        [_title setNumberOfLines:0];
    } else {
        [_descriptionText setLineBreakMode:NSLineBreakByTruncatingTail];
        [_descriptionText setNumberOfLines:1];

        [_title setLineBreakMode:NSLineBreakByTruncatingTail];
        [_title setNumberOfLines:1];
    }

    [self layoutIfNeeded];
}
Run Code Online (Sandbox Code Playgroud)

uitableview ios

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

以编程方式使用约束来集中UIIMageView

我正在开发一个iOS项目,我需要以编程方式为我的视图使用约束.我已经习惯了故事板,但由于项目规范的性质,我正在为这个特定项目使用xib.

我有一个MainViewController,在其中我在.h文件中创建以下属性:

@property (nonatomic, strong) IBOutlet UIImageView *backgroundImageView;
@property (nonatomic, strong) IBOutlet UIImageView *logoImage;
Run Code Online (Sandbox Code Playgroud)

我将这些UIImageView实例添加到我的XIB文件中,并通过Attributes检查器选择了适当的图像.

在我的.m文件中,我有一个addConstraints方法,它被调用viewDidLoad.在此方法中,我确保关闭将autoresizingMasks转换为约束:

self.backgroundImageView.translatesAutoresizingMaskIntoConstraints = NO;
self.logoImage.translatesAutoresizingMaskIntoConstraints = NO;
Run Code Online (Sandbox Code Playgroud)

然后,我设置了约束,以便背景图像占据整个superview:

id mainView = @{@"background": self.backgroundImageView};

//Set constraints so that the background takes up the entirety of the superview
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[background]|" options:0 metrics:nil views:mainView]];
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[background]|" options:0 metrics:nil views:mainView]];
Run Code Online (Sandbox Code Playgroud)

最后,我设置了约束,以便徽标视图位于视图的中心(这是我出错的地方):

// Width constraint
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:self.logoImage
                                                 attribute:NSLayoutAttributeWidth
                                                 relatedBy:NSLayoutRelationEqual
                                                    toItem:self
                                                 attribute:NSLayoutAttributeWidth
                                                multiplier:0.5
                                                  constant:0]];

// Height constraint
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:self.logoImage
                                                 attribute:NSLayoutAttributeHeight
                                                 relatedBy:NSLayoutRelationEqual …
Run Code Online (Sandbox Code Playgroud)

objective-c xib uiimageview ios autolayout

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

使从笔尖加载的视图尊重超级视图的顶部布局指南(导航栏底部)

我有一个UIViewController自定义的UINavigationBar(继承自它的超类)。

在此控制器中,我实例化另一个控制器UIViewController并将其视图添加为我的视图中的子视图,如下所示:

// I believe this should be 'as LocationPermissionsInfoViewController' but it crashed badly that way. Any ideas?
var permissionsView = UIViewController(nibName:"LocationPermissionsInfoView", bundle: nil) as UIViewController

    self.view.addSubview(permissionsView.view)
    permissionsView.view.frame = self.view.bounds
Run Code Online (Sandbox Code Playgroud)

LocationPermissionsInfoView是在 IB 中设计的,具有各种自动布局约束。但是,我希望该视图中存在的“contentView”遵守作为子视图添加的视图的顶部布局指南(准确地说是自定义导航栏的底部)。现在,IB 显然只允许我设置与界面中的顶级视图相关的约束。

关于如何实现这一目标有什么想法吗?理想情况下来自 IB 或LocationPermissionsInfoView控制器中的某个位置。

interface-builder uinavigationbar ios autolayout swift

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

Xcode UITableView 行在选择时未突出显示

我的 iPhone 应用程序上有一个工作表视图,并且正在使用 navigationController 实现第二个视图。

但是,当我尝试在初始视图上选择一个单元格时,它没有响应,即没有蓝色突出显示,没有选择。

任何人都可以建议我可能错过了什么,或者当用户点击单元格时负责实际选择单元格的是什么?

好的,谢谢您的建议 - 仍然没有运气。这是我的代码:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]autorelease];

        [cell setSelectionStyle: UITableViewCellSelectionStyleBlue]; 

        UIView *selectionView = [[[UIView alloc] init] autorelease];
        selectionView.backgroundColor =[UIColor redColor];
        cell.selectedBackgroundView = selectionView;
    }

    // format text

    cell.textLabel.font = [UIFont fontWithName:@"Arial" size:12];
    cell.textLabel.text = [tableArray objectAtIndex:indexPath.row];

        return cell;
}


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    //NSUInteger row = indexPath.row;
    //[DetailView …
Run Code Online (Sandbox Code Playgroud)

iphone xcode objective-c uitableview

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

我可以以编程方式检查UITableViewCell的样式吗?

在计算UITableViewCell的高度时,如果我可以告诉我的UITableViewCell设置的样式,那将非常有用.我没有在单元格本身看到任何属性.这可能吗?

objective-c uitableview ios

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

YouTube API 是否支持标签?

我正在开发一款 iOS 应用程序,可以让您开始 YouTube 直播。我想为此广播添加标签。

查看 API 文档上的此页面,我注意到可以为该snippet.tags[]属性设置一个值,这似乎正是我所需要的。GTLYouTubeLiveBroadcastSnippet.h然而,当我看着时;我看到以下属性:

@interface GTLYouTubeLiveBroadcastSnippet : GTLObject

@property (retain) GTLDateTime *actualEndTime;

@property (retain) GTLDateTime *actualStartTime;

@property (copy) NSString *channelId;

@property (retain) GTLDateTime *publishedAt;

@property (retain) GTLDateTime *scheduledEndTime;

@property (retain) GTLDateTime *scheduledStartTime;

@property (retain) GTLYouTubeThumbnailDetails *thumbnails;

@property (copy) NSString *title;
Run Code Online (Sandbox Code Playgroud)

但我没有看到任何有关标签的信息。Google 的朋友们——是否可以创建直播并添加标签?谢谢你!

youtube-api ios youtube-data-api youtube-livestreaming-api

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