我想UIImageView通过添加以下代码行来添加约束:
addConstraint(NSLayoutConstraint.constraintsWithVisualFormat("H:|[v0]|", options: NSLayoutFormatOptions(), metrics: nil, views: ["v0": userProfileImageView]))
Run Code Online (Sandbox Code Playgroud)
但是xcode告诉我这个错误:
我该如何解决这个错误?
我正在开发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)
然而,这会引发错误(错误展开为零).我该如何正确更改导航栏后退按钮的字体和颜色?感觉就像我没有修改正确的物品......
我的客户想要使用"无线安装应用"功能.
使用它,他可以直接从我的服务器下载应用程序,无需同步他的设备.我在互联网上搜索,我得到了一些信息,因为我需要两个文件
我知道如何创建(.ipa)文件,但我不知道(.plist)文件.如果有任何人知道如何创建(.plist)文件请分享您的想法.
我正在使用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) 我扩展了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()但它无法正常工作
我正在尝试从我的应用程序实现捕获图像和视频,现在从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) 我们可以在图像上设置下面的形状UIImageView.
任何的想法!
谢谢

我正在开发一个带有一些收费订阅的应用程序,我想为此添加应用程序内购买,所以任何人都可以帮助我在ios-10(objective-c)中找到帮助教程或示例.我一直在寻找它的例子,我得到的只是快速.先感谢您 !
我正在研究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,我也能理解
以下是我用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
ios ×9
objective-c ×7
iphone ×4
ios10 ×3
swift ×3
swift2 ×2
cocoa-touch ×1
swift3 ×1
uiimage ×1
uiimageview ×1
uisearchbar ×1
uitableview ×1
uiview ×1
xcode ×1