尝试从UIImage获取CIImage以便将其用于CIFilter,但在最后一行获得以下异常:
Execution was interrupted, reason: EXC_BREAKPOINT (code=EXC_I386_BPT, subcode=0x0)
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
import UIKit
UIGraphicsBeginImageContextWithOptions(CGSizeMake(100,100), false, 0)
let con:CGContextRef = UIGraphicsGetCurrentContext()
CGContextAddEllipseInRect(con, CGRectMake(0,0,100,100))
CGContextSetFillColorWithColor(con, UIColor.blueColor().CGColor)
CGContextFillPath(con)
let im:UIImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
let ciimage = CIImage(image: im) // <- Exception here
Run Code Online (Sandbox Code Playgroud)
更新: 根据建议不要将CIImage实例化为变量,我重新编写了我的初始代码片段以在操场中工作:
UIGraphicsBeginImageContextWithOptions(CGSizeMake(100,100), false, 0)
let con:CGContextRef = UIGraphicsGetCurrentContext()
CGContextAddEllipseInRect(con, CGRectMake(0,0,100,100))
CGContextSetFillColorWithColor(con, UIColor.blueColor().CGColor)
CGContextFillPath(con)
let im:UIImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
//let ciimage = CIImage(image: im) // <- this was causing an exception
let filter = CIFilter(name: "CIGaussianBlur", withInputParameters: [kCIInputRadiusKey: 10, kCIInputImageKey: CIImage(image: im)]) // …Run Code Online (Sandbox Code Playgroud) 我注意到,在触发的对话框关闭后,该按钮会获得以cdk为重点的类和cdk-program-focused .如果我点击任何地方效果消失.
app.component.html [片段]
<mat-cell *matCellDef="let element">
<span matTooltip="Delete" matTooltipPosition="right">
<button mat-icon-button color="warn" (click)="openDeleteAssociationDialog()">
<mat-icon>delete</mat-icon>
</button>
</span>
</mat-cell>
Run Code Online (Sandbox Code Playgroud)
在 *ngFor 循环中将数据源从数组传递到 mat-table 的方法是什么。即我使用 *ngFor 创建多个表,每个表都需要一个数据源,但是当我尝试以下操作时它不起作用:
<mat-table #table [dataSource]="dataSources[i]">
Run Code Online (Sandbox Code Playgroud)
而 'i' 是在 html 模板中预先定义的:
<mat-expansion-panel *ngFor="let customer of customers; let i = index">
Run Code Online (Sandbox Code Playgroud)
更新:
以下对我有用,我将 dataSource 添加到每个客户对象,而不是将其分开并尝试通过“i”索引访问
<mat-table #table [dataSource]="customer.dataSource">
Run Code Online (Sandbox Code Playgroud)