我想在Swift 3 Xcode 8中启动新的应用程序并支持iOS 8.4/9.x如何处理核心数据?
我正在尝试将 Firebase 从 7.10 更新到 7.11。如果您想发布在 Xcode 8 中运行 AdMob 的应用程序,则需要它。如何更新我的应用程序中的 Firebase 软件?
我正在使用可可豆荚。谢谢!
这是我的代码
[cell.label.layer setCornerRadius:cell.label.frame.size.width/2];
Run Code Online (Sandbox Code Playgroud)
这是我尝试过的:-
cell.label.clipsToBounds = YES;
Run Code Online (Sandbox Code Playgroud)
也试过:-
cell.label.layer.masksToBounds = YES;
Run Code Online (Sandbox Code Playgroud)
我也进口了:-
#import <QuartzCore/QuartzCore.h>
Run Code Online (Sandbox Code Playgroud)
这些方法都不起作用。
此外,我已经在 IOS 9 和 IOS 10 以及模拟器和设备中进行了尝试,那里的任何人都面临相同的问题?
回答
经过一些试验和错误方法后,我发现将绝对值传递给拐角半径参数是有效的。
[cell.label.layer setCornerRadius:20.0];
Run Code Online (Sandbox Code Playgroud)
这涉及到最后一个问题,当将 Storyboard 用于 tableview 时,如何动态设置标签的角半径。
我知道这个问题已经问过很多次了,他们的解决方案也可用,但对我来说没什么用.我正在使用Swift3,我想为了这个目的绕过UIView的任何两个方面我找到了以下解决方案
以下是我上述解决方案的代码片段
extension UIView {
/**
Rounds the given set of corners to the specified radius
- parameter corners: Corners to round
- parameter radius: Radius to round to
*/
func round(corners: UIRectCorner, radius: CGFloat) -> Void {
layer.addSublayer(_round(corners: corners, radius: radius))
}
/**
Rounds the given set of corners to the specified radius with a border
- parameter corners: Corners to round
- parameter radius: Radius to round to
- parameter borderColor: The border color
- parameter borderWidth: …Run Code Online (Sandbox Code Playgroud) 我在Xcode 8中运行时收到此消息。
Incorrect NSStringEncoding value 0x8000100 detected. Assuming NSASCIIStringEncoding. Will stop this compatiblity mapping behavior in the near future.
我该如何追踪呢?我0x8000100在项目中找不到任何地方。
我正在研究将Swift 2.3转换为Swift 3.0;
Swift 2.3代码:
extension ContextDidSaveNotification: CustomDebugStringConvertible {
public var debugDescription: String {
var components = [notification.name]
components.append(managedObjectContext.description)
for (name, set) in [("inserted", insertedObjects), ("updated", updatedObjects), ("deleted", deletedObjects)] {
let all = set.map { $0.objectID.description }.joinWithSeparator(", ")
components.append("\(name): {\(all)}")
}
return components.joinWithSeparator(" ")
}
}
Run Code Online (Sandbox Code Playgroud)
Swift 3.0代码:
extension ContextDidSaveNotification: CustomDebugStringConvertible {
public var debugDescription: String {
var components = [notification.name]
components.append(Notification.Name(rawValue: managedObjectContext.description))
for (name, set) in [("inserted", insertedObjects), ("updated", updatedObjects), ("deleted", deletedObjects)] {
let all = set.map { $0.objectID.description …Run Code Online (Sandbox Code Playgroud) 在我的项目中,我有一个视图控制器,我想在其他UIView中嵌入WKWebView,这个UIView名为viewForEmbeddingWebView,我在故事板中创建了(图片中的灰色).
我在ViewController中实现了这个逻辑:
import UIKit
import WebKit
class ViewController: UIViewController, WKUIDelegate {
var webView: WKWebView!
@IBOutlet weak var viewForEmbeddingWebView: UIView!
override func viewDidLoad() {
super.viewDidLoad()
webView = WKWebView(frame: viewForEmbeddingWebView.frame, configuration: WKWebViewConfiguration() )
self.viewForEmbeddingWebView.addSubview(webView)
self.webView.allowsBackForwardNavigationGestures = true
let myURL = URL(string: "https://www.apple.com")
let myRequest = URLRequest(url: myURL!)
webView.load(myRequest)
}
}
Run Code Online (Sandbox Code Playgroud)
它显示了WKWebView但边界看起来不对(第一种:它不适合viewForEmbeddingWebView的边界,第二种:顶部有一个白色间隙).我已经读过我必须在苹果网站https://developer.apple.com/reference/webkit/wkwebview上使用WKWebView,但他们的例子不是我的情况,因为他们只展示如何处理加载WKWebView的情况ViewController的整个视图.但我需要将它嵌入到另一个视图中,因为我以后还需要另一个ui围绕这个WKWebView.在WKWebView之前有WebView,但是自iOS 8出现以来我们必须使用WKWebView.请帮助,因为我检查了很多材料,但没有找到适合Swift 3和Xcode 8的答案.
我在iOS 10.2中使用Xcode 8和Swift 3.
我在swift 3中使用以下代码来调出日期选择器.
import UIKit
class ViewController: UIViewController, UITextFieldDelegate {
@IBOutlet var eventStartText: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
eventStartText.delegate = self
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// MARK: TextField Delegate
func datePickerChanged(sender: UIDatePicker) {
let formatter = DateFormatter()
//formatter.dateStyle = .full
formatter.dateStyle = .long
formatter.timeStyle = .none
eventStartText.text = formatter.string(from: sender.date)
print("Try this at home")
}
func textFieldDidBeginEditing(_ textField: UITextField) …Run Code Online (Sandbox Code Playgroud) 我们的项目针对所有iPAD运行,我们遇到了一个问题,例如我们有8个按钮垂直放置在屏幕上,限制被添加为垂直间距,它们在iPAD 9.7英寸上看起来很好,但它们在iPAD 12.9上显得非常大,所以问题是,有没有什么好方法可以更好地使用屏幕空间,如果它是iPAD 12.9则添加额外的UIView.我已经研究过使用大小类,但我相信所有iPAD都有一个大小类,我想要的是如果有一种方法可以使用"接口"构建器为不同的iPAD大小设置不同的UI