小编kb9*_*920的帖子

无法在swift 2中转换类型'[NSLayoutConstraint]'错误的值

我想UIImageView通过添加以下代码行来添加约束:

addConstraint(NSLayoutConstraint.constraintsWithVisualFormat("H:|[v0]|", options: NSLayoutFormatOptions(), metrics: nil, views: ["v0": userProfileImageView]))
Run Code Online (Sandbox Code Playgroud)

但是xcode告诉我这个错误:

在此输入图像描述

我该如何解决这个错误?

ios nslayoutconstraint swift swift2

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

快速更改后退按钮的字体和颜色

我正在开发Swift 2.2中的应用程序.现在我想更改某个视图的后退按钮字体和颜色.有问题的视图有一个导航控制器作为它的父控制器.

我已尝试在ViewController的viewDidLoad中运行以下两行

self.navigationController!.navigationItem.backBarButtonItem!.setTitleTextAttributes([NSFontAttributeName: UIFont(name: "Andes Rounded", size: 17)!], forState: .Normal)
self.navigationItem.backBarButtonItem!.setTitleTextAttributes([NSFontAttributeName: UIFont(name: "Andes Rounded", size: 17)!], forState: .Normal)
Run Code Online (Sandbox Code Playgroud)

不会抛出任何错误,但它对后退按钮没有任何影响.我也试过运行这两个

self.navigationController!.navigationItem.leftBarButtonItem!.setTitleTextAttributes([NSFontAttributeName: UIFont(name: "Andes Rounded", size: 17)!], forState: .Normal)   
self.navigationItem.leftBarButtonItem!.setTitleTextAttributes([NSFontAttributeName: UIFont(name: "Andes Rounded", size: 17)!], forState: .Normal)
Run Code Online (Sandbox Code Playgroud)

然而,这会引发错误(错误展开为零).我该如何正确更改导航栏后退按钮的字体和颜色?感觉就像我没有修改正确的物品......

uinavigationbar ios swift swift2

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

使用Xcode创建无线清单文件(.plist扩展名)

我的客户想要使用"无线安装应用"功能.

使用它,他可以直接从我的服务器下载应用程序,无需同步他的设备.我在互联网上搜索,我得到了一些信息,因为我需要两个文件

  1. 应用(.ipa)文件
  2. 清单(.plist)文件.

我知道如何创建(.ipa)文件,但我不知道(.plist)文件.如果有任何人知道如何创建(.plist)文件请分享您的想法.

iphone xcode cocoa-touch objective-c

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

iOS:推送通知未在iOS 10中显示字典信息

我正在使用XCode 8 Beta,iOS 10版本中的推送通知.我在设备上收到了推送通知.当我点击通知时,它触发了UNUserNotificationCenterDelegate的委托,app被打开,但它没有在userinfo中显示任何响应.我是否需要在服务器端更改iOS 10中发送推送的参数.以下是我的代码.

    UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound categories:nil];
    [application registerUserNotificationSettings:settings];

    UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
    center.delegate = self;
    [center requestAuthorizationWithOptions:(UNAuthorizationOptionBadge | UNAuthorizationOptionSound | UNAuthorizationOptionAlert) completionHandler:^(BOOL granted, NSError * _Nullable error) {
        if (!error) {
            NSLog(@"request authorization succeeded!");
        }
    }];


- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler {

    NSLog(@"Notification is triggered");
    completionHandler(UNNotificationPresentationOptionAlert);
}

- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)())completionHandler {

    NSLog(@"Tapped in notification");
    NSLog(@"%@",response.notification);
    NSString *actionIdentifier = response.actionIdentifier;

    if ([actionIdentifier isEqualToString:@"com.apple.UNNotificationDefaultActionIdentifier"] ||
        [actionIdentifier …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c apple-push-notifications ios ios10

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

使用自动布局为UIView应用渐变背景

我扩展了UIView以添加addGradientWithColor()方法来获取渐变背景:

 extension UIView {
   func addGradientWithColor() {
     let gradient = CAGradientLayer()
     gradient.frame = self.bounds
     gradient.colors = [gradientEndColor.CGColor,  gradientStartColor.CGColor]
     gradient.startPoint = CGPointMake(1,0)
     gradient.endPoint = CGPointMake(0.2,1)
    self.layer.insertSublayer(gradient, atIndex: 0)
  } } 
Run Code Online (Sandbox Code Playgroud)

我的问题是当我运行横向模式时,UIView没有被拉伸

override func viewDidLayoutSubviews() {
    super.viewDidLayoutSubviews()
    self.view.addGradientWithColor() }
Run Code Online (Sandbox Code Playgroud)

我试图调用viewDidLayoutSubviews()但它无法正常工作

这是屏幕截图:

删除viewDidLayoutSubviews()后 在此输入图像描述

objective-c uiview ios cagradientlayer swift3

8
推荐指数
2
解决办法
5858
查看次数

iOS 10 - Objective-C:如何实现AVCapturePhotoOutput()来捕获图像和视频?

我正在尝试从我的应用程序实现捕获图像和视频,现在从iOS 10开始,"AVCaptureStillImageOutput"已被弃用.

请帮我在Objective-C中实现AVCapturePhotoOutput.

这是我的示例代码:

_avCaptureOutput = [[AVCapturePhotoOutput alloc]init];
_avSettings = [AVCapturePhotoSettings photoSettings];


AVCaptureSession* captureSession = [[AVCaptureSession alloc] init];
[captureSession startRunning];



AVCaptureConnection *connection = [self.movieOutput connectionWithMediaType:AVMediaTypeVideo];

if (connection.active)
{
    //connection is active
    NSLog(@"Connection is active");

    id previewPixelType = _avSettings.availablePreviewPhotoPixelFormatTypes.firstObject;
    NSDictionary *format = @{(NSString*)kCVPixelBufferPixelFormatTypeKey:previewPixelType,(NSString*)kCVPixelBufferWidthKey:@160,(NSString*)kCVPixelBufferHeightKey:@160};

    _avSettings.previewPhotoFormat = format;

    [_avCaptureOutput capturePhotoWithSettings:_avSettings delegate:self];


}
else
{
    NSLog(@"Connection is not active");
    //connection is not active
    //try to change self.captureSession.sessionPreset,
    //or change videoDevice.activeFormat
}
Run Code Online (Sandbox Code Playgroud)

iphone objective-c ios avcapturesession ios10

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

uiimageview上的特殊形状图像

我们可以在图像上设置下面的形状UIImageView.

任何的想法!

谢谢

在此输入图像描述

objective-c uiimageview uiimage ios

7
推荐指数
3
解决办法
3949
查看次数

如何在app中实现在目标c中购买ios 10

我正在开发一个带有一些收费订阅的应用程序,我想为此添加应用程序内购买,所以任何人都可以帮助我在ios-10(objective-c)中找到帮助教程或示例.我一直在寻找它的例子,我得到的只是快速.先感谢您 !

objective-c in-app-purchase ios ios10

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

如何在swift的右侧设置UiSearchBar搜索图标

我正在研究Swift.

作为常规SearchBar默认情况下它看起来像Follow Pic(1). 在此输入图像描述

但根据我们的设计要求,我需要将其更改为以下Pic(2).

在此输入图像描述

我尝试使用以下代码,如下面的Pic(3)

在此输入图像描述

**当我尝试以下代码时,正确的视图正在隐藏,我无法看到文本字段右视图

搜索图标完全不可见**

let searchField = (searchBar.valueForKey("_searchField") as! UITextField)
searchField.layer.cornerRadius = 15;


    let searchIcon = searchField.leftView!
    if (searchIcon is UIImageView) {
        print("yes")
    }

    searchField.rightView = searchIcon
  searchField.leftViewMode = .Never
searchField.rightViewMode = .Always
Run Code Online (Sandbox Code Playgroud)

任何人都可以帮助我获得要求.如果您提供甚至客观C,我也能理解

iphone uisearchbar uisearchbardisplaycontrol ios swift

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

UITableView滑动手势与UITableViewCell滑动冲突

以下是我用2手指轻扫的代码UITableView:

UISwipeGestureRecognizer *leftSwipe = [UISwipeGestureRecognizer new];
[leftSwipe addTarget:self action:@selector(nextDay)];
leftSwipe.numberOfTouchesRequired = 2;
leftSwipe.direction = UISwipeGestureRecognizerDirectionLeft;
leftSwipe.delegate = self;
[leftSwipe setCancelsTouchesInView:YES];
[tableViewTasks addGestureRecognizer:leftSwipe];

UISwipeGestureRecognizer *rightSwipe = [UISwipeGestureRecognizer new];
[rightSwipe addTarget:self action:@selector(previousDay)];
rightSwipe.numberOfTouchesRequired = 2;
rightSwipe.direction = UISwipeGestureRecognizerDirectionRight;
rightSwipe.delegate = self;
[rightSwipe setCancelsTouchesInView:YES];
[tableViewTasks addGestureRecognizer:rightSwipe];  
Run Code Online (Sandbox Code Playgroud)

我正在使用SWTableViewCell,它具有左右(单击)gestureRecognisers.
UITableView使用2个手指向左/向右滑动时,SWTableViewCell在此之后也会触发左右手势.
如何制止冲突?

objective-c uitableview ios uiswipegesturerecognizer swtableviewcell

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