请查看附件图片.Viewcontroller的视图背景颜色为蓝色.如您所见,此颜色延伸到状态栏下方和主页指示器下方.底部有一个白色视图,这是一个按钮.这里的白色视图位于安全布局指南中.
我希望在家庭指示器下方延伸相同的白色,而不为iPhone-X添加任何其他视图.
这该怎么做?
我做了什么:
已删除的派生数据,重新启动的xcode,编辑器 - >Refresh all views
我得到Designables在故事板构建失败当我点击编辑- > Refresh all views.
请检查以下代码.我错过了什么?当我从属性检查器更改@IBInspectable值时,Textfiled未在故事板中更新.
import UIKit
import QuartzCore
@IBDesignable
class BorderedFloatingTF: UITextField {
required init?(coder aDecoder:NSCoder) {
super.init(coder:aDecoder)
setup()
}
override init(frame:CGRect) {
super.init(frame:frame)
setup()
}
override func textRect(forBounds bounds: CGRect) -> CGRect {
return bounds.insetBy(dx: 20, dy: 0)
}
override func editingRect(forBounds bounds: CGRect) -> CGRect {
return textRect(forBounds: bounds)
}
override func prepareForInterfaceBuilder() {
super.prepareForInterfaceBuilder()
setup()
}
// properties..
@IBInspectable var enableTitle : Bool = false …Run Code Online (Sandbox Code Playgroud) 从这个答案:
这是接受的答案建议为视图更改设置动画:
_addBannerDistanceFromBottomConstraint.constant = 0
UIView.animate(withDuration: 5) {
self.view.layoutIfNeeded()
}
Run Code Online (Sandbox Code Playgroud)
layoutIfNeeded当我们不更改帧时,为什么要打电话.我们正在改变约束,所以(根据这个其他答案)我们不应该调用setNeedsUpdateConstraints吗?
同样,这个备受好评的答案说:
如果稍后发生某些变化会使您的某个约束无效,则应立即删除约束并调用setNeedsUpdateConstraints
我确实尝试过使用它们.使用setNeedsLayout我的视图在左侧正确设置动画
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func animate(_ sender: UIButton) {
UIView.animate(withDuration: 1.8, animations: {
self.centerXConstraint.isActive = !self.centerXConstraint.isActive
self.view.setNeedsLayout()
self.view.layoutIfNeeded()
})
}
@IBOutlet weak var centerYConstraint: NSLayoutConstraint!
@IBOutlet var centerXConstraint: NSLayoutConstraint!
}
Run Code Online (Sandbox Code Playgroud)
但是使用setNeedsUpdateConstraints 不动画,它只是将视图快速向左移动.
import UIKit
class ViewController: UIViewController …Run Code Online (Sandbox Code Playgroud) 如何使用使用 iPhonetrue-depth相机捕获的深度数据来区分真实的人类 3D 面部和相同的照片?要求是将其用于身份验证。
我做了什么:创建了一个示例应用程序来获取AVDepthData相机前面的连续流。
当我单击视图框并拖动以放大视图时,视图不会放大.但相反,鼠标等待指示器将持续一秒钟,然后整个xcode将崩溃.
这是在我的代码8.2更新后发生的.所以我尝试安装xcode 8.1,问题仍然存在于一个特定项目中.所有其他项目都运作良好.故事板中没有警告或冲突.我不记得改变任何设置.
附加崩溃日志:CRASH_LOG
我正在使用 UIView 扩展将渐变层应用于 UIView。我需要在滚动 tableview 时在运行时更改渐变颜色。我使用滚动视图 contentoffset 值来更新渐变颜色。
我尝试过的: 我尝试从超级图层中删除图层并创建一个具有新颜色的新渐变图层。但是应用程序出现内存问题,用户界面有时会冻结。
是否可以在运行时更新 CAGradientLayer 渐变颜色?
extension UIView {
func applyGradient(withColours colours: [UIColor], gradientOrientation orientation: GradientOrientation) {
let gradient: CAGradientLayer = CAGradientLayer()
gradient.frame = self.bounds
gradient.colors = colours.map { $0.cgColor }
gradient.startPoint = orientation.startPoint
gradient.endPoint = orientation.endPoint
self.layer.insertSublayer(gradient, at: 0)
}
}
Run Code Online (Sandbox Code Playgroud) 尝试'是'关键字.
// Initialize the dictionary
let dict = ["name":"John", "surname":"Doe"]
// Check if 'dict' is a Dictionary
if dict is Dictionary {
print("Yes, it's a Dictionary")
}
Run Code Online (Sandbox Code Playgroud)
这将给出一个错误,说"'是'总是如此".我只想检查对象是否是字典.它可以与任何键对任何值对.
密钥是可清除的,它不接受Any关键字.
在我的项目中,我使用一些代码来处理后退按钮,如下所示.
NSMutableArray *VCs = [NSMutableArray arrayWithArray: self.navigationController.viewControllers];
if ([[VCs objectAtIndex:[VCs count] - 2] isKindOfClass:[LoginViewController class]])
{
[VCs removeObjectAtIndex:[VCs count] - 2];
[VCs removeObjectAtIndex:[VCs count] - 2];
}
[self.navigationController setViewControllers: VCs];
Run Code Online (Sandbox Code Playgroud)
在iOS 7中,我得到了理想的结果.但是对于iOS版本8.2,可变数组VC中的值只是堆栈中的当前或topViewController.但后退按钮将导航到所有以前的viewcontrollers.但是导航堆栈中没有一个存在.在ios8中导航处理有什么变化吗?
我想从堆栈中删除登录屏幕viewcontroller,以便在单击后退按钮时,它不会返回到登录屏幕.我仅在iOS 8.2中遇到此问题(可能在iOS 8及更高版本中).可能是什么问题?
编辑:
在prepareForSegue:中,我使用以下代码:
if([[segue identifier] isEqualToString:@"mediaDetailSegue1"])
{
MovieDetailViewController *movieDetail;
if(isIOS8SystemVersion)
{
movieDetail = ([[segue destinationViewController]viewControllers][0]);
}
else
{
movieDetail = [segue destinationViewController];
}
movieDetail.videoData = [_mediaContentArray objectAtIndex:selectedIndex];
}
Run Code Online (Sandbox Code Playgroud)
所以对于iOS版本大于8的代码
movieDetail = ([[segue destinationViewController]viewControllers][0]);
Run Code Online (Sandbox Code Playgroud)
叫做.我认为这是导致这个问题的原因.我做错了吗?
我正在使用 AVFoundationAVCaptureSession捕获视频以进行实时流传输(使用 发送到服务器RTMP protocol)。
的回调委托方法AVCaptureVideoDataOutputSampleBufferDelegate并AVCaptureAudioDataOutputSampleBufferDelegate返回CMSampleBufferRef以下方法:
- (void)captureOutput:(AVCaptureOutput *)captureOutputdidOutputSampleBuffer:(CMSampleBufferRef)sampleBufferfromConnection:(AVCaptureConnection *)connection\nRun Code Online (Sandbox Code Playgroud)\n根据此链接的内容,我可以使用此链接将此缓冲区内容转换为文件。
\n喜欢
\nNSURL *url = \xe2\x80\xa6;\nAVAssetWriter *assetWriter = [AVAssetWriter assetWriterWithURL:url fileType:AVFileTypeMPEG4 error:nil];\nAVAssetWriterInput *videoInput = [[AVAssetWriterInput alloc] initWithMediaType:AVMediaTypeVideo outputSettings:nil];\nvideoInput.expectsMediaDataInRealTime = YES;\nAVAssetWriterInput *audioInput = [[AVAssetWriterInput alloc] initWithMediaType:AVMediaTypeAudio outputSettings:nil];\naudioInput.expectsMediaDataInRealTime = YES;\nif ([assetWriter canAddInput:videoInput]) {\n [assetWriter addInput:videoInput];\n}\nif ([assetWriter canAddInput:audioInput]) {\n [assetWriter addInput:audioInput];\n}\nRun Code Online (Sandbox Code Playgroud)\n但我没有得到此文件转换所涉及的确切逻辑。这didOutputSampleBuffer是一帧一帧捕获(未压缩)的原始数据,我想以一定的间隔将这些帧转换为单个文件。比如每 10 秒左右一次。我想将此文件发送到服务器。
有人可以简要介绍一下如何AVAssetWriter工作吗?或者如果我做错了什么可以纠正我。
我只有纵向应用程序,只有横向模式的一个屏幕.
我做了什么:我创建了一个UINavigationController子类并重写了以下内容:
import UIKit
class LandscapeVCNavigationController: UINavigationController {
override func viewDidLoad() {
super.viewDidLoad()
}
override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
return .landscape
}
override var preferredInterfaceOrientationForPresentation: UIInterfaceOrientation {
return .landscapeLeft
}
}
Run Code Online (Sandbox Code Playgroud)
然后使用此navigationController来呈现我的横向视图控制器,如下所示:
if let vc = storyboard?.instantiateViewController(withIdentifier: StoryBoardIdentifiers.playerVCStoryboardIdentifier) as? PlayerViewController {
let navController = LandscapeVCNavigationController.init(rootViewController: vc)
present(navController, animated: true, completion: {
})
}
Run Code Online (Sandbox Code Playgroud)
这很好用.
我正在使用ios中的AVPlayer创建自定义视频播放器(OBJECTIVE-C).我有一个设置按钮,点击后会显示可用的视频尺寸和音频格式.以下是设计:
所以,我想知道:
1).如何从视频网址(而非本地视频)获取可用尺寸?
2).即使我能够获得尺寸,我可以在AVPlayer中播放时在可用尺寸之间切换吗?
任何人都可以给我一个提示吗?
检查下图.我需要强调聚焦细胞,使其高于细胞collectionView.
我知道我必须改变zIndex聚焦细胞.怎么做?
我需要逻辑.我的代码在objective-c.
这是为了tvOS但iOS我认为代码也可以在这里工作.
我收到以下错误
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** setObjectForKey: object cannot be nil (key: objectid)'
Run Code Online (Sandbox Code Playgroud)
它是字典还是核心数据?我无法弄清楚崩溃发生在哪里.任何想法?
2015-03-18 12:47:23.239 OneChannelApp[3039:6403] INFO: GoogleAnalytics 3.10 -[GAIBatchingDispatcher didSendHits:] (GAIBatchingDispatcher.m:219): 2 hit(s) sent
2015-03-18 12:47:27.804 OneChannelApp[3039:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** setObjectForKey: object cannot be nil (key: objectid)'
*** First throw call stack:
(0x30668f83 0x3ae19ccf 0x305a48f3 0xbf357 0x32ea06df 0x3301643f 0x32f33d63 0x32f33b6d 0x32f33b05 0x32e85d59 0x32b0362b 0x32afee3b 0x32afeccd 0x32afe6df 0x32afe4ef 0x32af821d 0x30634255 0x30631bf9 0x30631f3b 0x3059cebf 0x3059cca3 0x354a2663 0x32ee914d 0x20555d …Run Code Online (Sandbox Code Playgroud) ios ×11
swift ×7
objective-c ×5
iphone ×4
avfoundation ×3
animation ×2
xcode ×2
arkit ×1
autolayout ×1
avplayer ×1
coreml ×1
crash ×1
dictionary ×1
ibdesignable ×1
ipad ×1
iphone-x ×1
transition ×1
tvos ×1
uiview ×1
video ×1
view ×1