我正在尝试构建一个面向对象的iOS应用程序,我在从一个swift类文件调用表重新加载(ui交互)时遇到问题.
如果我在没有对象的情况下工作并在InterfaceController的viewDidLoad方法中写下所有内容,那么一切正常......但如果我把它放到类中则不行.
我正在使用异步请求来从Web服务加载json数据.收到数据后,我将此数据用作表格视图的数据源.似乎tableview在启动后没有数据初始化,因此在完成异步请求后在tableview上调用reload()是必要的.
所以这里有详细信息:
主TableController
import UIKit;
class DeviceOverview: UITableViewController {
@IBOutlet var myTableView: UITableView!
var myDevices = Array<String>();
var myDevicesSection = NSMutableDictionary()
var deviceObjects = Array<NSDictionary>();
var mappingSectionIndex = Array<String>();
var sharedUserDefaults = NSUserDefaults(suiteName: "group.barz.fhem.SharingDefaults")
// THIS IS AN ATTEMPT TO give the class itself as PARAMETER
// ALSO TRIED TO USE myTableView (IBOutlet)
var fhem :FHEM = FHEM(tableview : self)
override func viewDidLoad() {
super.viewDidLoad()
}
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return self.fhem.sections.count
}
override func …Run Code Online (Sandbox Code Playgroud) 我正在创建一个QR码并将其存储为UIImage.现在我希望能够使用UIActivityViewController发送它,但不知何故它失败了:
func generateQRCode(from string: String) -> UIImage? {
let data = string.data(using: String.Encoding.ascii)
if let filter = CIFilter(name: "CIQRCodeGenerator") {
filter.setValue(data, forKey: "inputMessage")
let transform = CGAffineTransform(scaleX: 3, y: 3)
if let output = filter.outputImage?.applying(transform) {
return UIImage(ciImage: output)
}
}
return nil
}
Run Code Online (Sandbox Code Playgroud)
然后我调用该函数并将其存储为UIImage:
let image = generateQRCode(from: "Create my Code")
imgQRCode.image = image
Run Code Online (Sandbox Code Playgroud)
导出按钮使用以下操作:
@IBAction func shareButtonClicked(sender: UIButton) {
let objectsToShare = [imgQRCode.image!] as [AnyObject]
let activityVC = UIActivityViewController(activityItems: objectsToShare, applicationActivities: nil)
activityVC.popoverPresentationController?.sourceView = sender
self.present(activityVC, animated: true, …Run Code Online (Sandbox Code Playgroud) 我有一个我想测试的模态组件。但它总是抱怨“找不到名称'ngbNav'的导出”。关于如何解决这个问题的任何想法都会很棒。
Error: Export of name 'ngbNav' not found!
at cacheMatchingLocalNames (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/__ivy_ngcc__/fesm2015/core.js:13112:1)
at resolveDirectives (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/__ivy_ngcc__/fesm2015/core.js:12871:1)
at elementStartFirstCreatePass (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/__ivy_ngcc__/fesm2015/core.js:21229:1)
at ??elementStart (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/__ivy_ngcc__/fesm2015/core.js:21271:1)
at TemplateModalComponent_Template (ng:///TemplateModalComponent.js:381:9)
at executeTemplate (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/__ivy_ngcc__/fesm2015/core.js:12129:1)
at renderView (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/__ivy_ngcc__/fesm2015/core.js:11899:1)
at renderComponent (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/__ivy_ngcc__/fesm2015/core.js:13509:1)
at renderChildComponents (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/__ivy_ngcc__/fesm2015/core.js:11700:1)
at renderView (http://localhost:9876/_karma_webpack_/node_modules/@angular/core/__ivy_ngcc__/fesm2015/core.js:11925:1)
Run Code Online (Sandbox Code Playgroud)
模板modal.component.html
<div class="modal-header">
<h4 class="modal-title" ngbTooltip="{{template ? template.id : ''}}" triggers="click:blur">{{"template_edit" | translate}}</h4>
<button type="button" class="close" aria-label="Close" (click)="activeModal.dismiss('Cross click')">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form class="form" [formGroup]="this.templateFormGroup">
<div formGroupName="template">
<div class="row">
<div class="col-md-6">
<div class="form-group row">
<label class="col-sm-3 col-form-label">Name</label>
<div class="col-sm-9"> …Run Code Online (Sandbox Code Playgroud) ios ×2
swift ×2
angular ×1
angular9 ×1
ng-bootstrap ×1
qr-code ×1
swift3 ×1
testing ×1
uitableview ×1