我的图表库有问题.我面临的问题是条形图在我的视图边界内"不适合".下图显示,第一个和最后一个条都被切成两半,最高条的标签也被部分切割.
当我在网上搜索时,我得到了以下主题https://github.com/danielgindi/Charts/issues/353,这似乎描述了完全相同的问题.
我使用一个简单的数据集,其中包含6个索引的随机数.数据将添加到图表中,如下所示:
let values: [Int] = [5, 8, 1, 2, 1, 2]
var dataEntries: [BarChartDataEntry]
for i in 0..<values.count {
let dataEntry = BarChartDataEntry(x: Double(i), y: Double(values[i]))
dataEntries.append(dataEntry)
}
let chartDataSet = BarChartDataSet(values: dataEntries, label: "Count")
let chartData = BarChartData(dataSet: chartDataSet)
barChartView.data = chartData
Run Code Online (Sandbox Code Playgroud)
希望有人可以帮助我.提前致谢!
在我的项目中,我在collectionView中使用了tableView,并且还使用了pageControl.当我水平滑动集合视图时,我也想切换pageControl,但它无法正常工作.我使用scrollViewDidScroll方法切换pageControl为collectionViewSwipes.但问题是,当tableView scrollls scrollViewDidScroll方法将再次调用时.那么有什么不同的方法或任何解决方案来解决这个问题.
请查看以下链接.
TableView方法
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
{
return model.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
{
cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! FbHomeCell
cell.btnPushImage.tag = indexPath.row
cell.collectionView.tag = indexPath.row
return cell
}
Run Code Online (Sandbox Code Playgroud)
CollectionView方法
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int
{
return model[collectionView.tag].count
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell
{
collCell = collectionView.dequeueReusableCell(withReuseIdentifier: …Run Code Online (Sandbox Code Playgroud) 我正在研究REST API管理器.这是一个错误,我无法解决它.我得到的错误如下所示.
import Foundation
import Alamofire
import SwiftyJSON
class RestApiManager {
var resources: JSON = [
"resources": [
"resourceA": []
]
]
let apiUrl: String
let apiUsername: String
let apiPassword: String
init(apiUrl: String, apiUsername: String, apiPassword: String) {
self.apiUrl = apiUrl
self.apiUsername = apiUsername
self.apiPassword = apiPassword
getApiResourceA() { responseObject, error in
let resourceA = JSON(responseObject!)
self.resources["resources"]["resourceA"] = resourceA
}
}
func collectDataFromApi(completionHandler: (responseObject: NSDictionary?, error: NSError?) -> ()) {
prepareHttpRequest(completionHandler)
}
func prepareHttpRequest(completionHandler: (responseObject: NSDictionary?, error: NSError?) -> ()) …Run Code Online (Sandbox Code Playgroud) 我通过 SourceTree 使用版本控制作为 GitHub,但它从 8 月 13 日开始失败,以下是我从 GitHub 得到的错误。
远程:2021 年 8 月 13 日移除了对密码身份验证的支持。请改用个人访问令牌。远程:请参阅https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ 了解更多信息。
有人知道问题出在哪里,或者我如何使用个人访问令牌?
我正在做一个通过地图在线送餐的项目。所以用户应该知道厨师的位置。当用户点击注释时,它应该查看厨师的食物菜单。所以当用户点击我需要调用厨师 ID。我可以根据标签值调用厨师ID。
**Juntos.swift**
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) ->
MKAnnotationView?
{
var annotationView =
mapView.dequeueReusableAnnotationView(withIdentifier: "identifier")
if annotationView == nil
{
annotationView = MKAnnotationView(annotation: annotation,
reuseIdentifier: "identifier")
annotationView!.canShowCallout = true
}
else
{
annotationView?.annotation = annotation
}
guard !(annotation is MKUserLocation) else
{
return nil
}
if iamA == "COOK"
{
annotationView!.image = UIImage(named: "foodie")
}
else
{
annotationView!.image = UIImage(named: "cook")
}
return annotationView
}
func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView)
{
// how can i …Run Code Online (Sandbox Code Playgroud) 我有一个 Objective-C iPhone 应用程序,目前我正在使用下面的代码来获取连接的 Wifi 名称。但它在 iOS 13 中不起作用。如何在 iOS 13 中获取已连接的 Wifi SSID?
目前我在 Swift 中使用以下代码:
public class SSID {
class func fetch() -> String {
var currentSSID = ""
if let interfaces = CNCopySupportedInterfaces() {
for i in 0..<CFArrayGetCount(interfaces) {
let interfaceName = CFArrayGetValueAtIndex(interfaces, i)
let rec = unsafeBitCast(interfaceName, to: AnyObject.self)
let unsafeInterfaceData = CNCopyCurrentNetworkInfo("\(rec)" as CFString)
if let interfaceData = unsafeInterfaceData as? [String: AnyObject] {
currentSSID = interfaceData["SSID"] as! String
let BSSID = interfaceData["BSSID"] as! String
let …Run Code Online (Sandbox Code Playgroud) 我刚开始使用Swift.所以我创建了一个带有标签,按钮和文本字段的简单应用程序.单击该按钮时,应用程序必须使用文本字段的文本更改标签.
class ViewController: UIViewController {
@IBOutlet weak var textLabel: UILabel!
@IBOutlet weak var textField: UITextField!
@IBAction func updateButton(sender: UIButton) {
textLabel.text = "Hi \(textField.text) "
}
Run Code Online (Sandbox Code Playgroud)
结果是
嗨可选("TextOfTextField")
好的.所以这是一个非常简单的问题.
我希望有一个人可以帮助我.
swift ×6
ios ×5
swift3 ×2
badge ×1
charts ×1
github ×1
ios-charts ×1
ios13 ×1
iphone ×1
objective-c ×1
optional ×1
pagecontrol ×1
ssid ×1
string ×1
uitableview ×1
xcode ×1