我一直试图隐藏我的表单并使其仅在用户单击按钮时显示。但出于某种原因,我创建的函数从不工作,我的代码有问题吗?我看到了很多使用的例子,angular.module我试过了,但我总是收到一条错误消息。
transfer.component.html
<form [formGroup]="AddRiciverForm" id="AddRiciverForm" (ngSubmit)="addRiciverFunc()" *ngIf="show">
<div class="container">
<div class="row">
<div class="col-sm-6 col-sm-offset-3">
<p><input type="email" id="emailTo" formControlName="emailTo" placeholder="Reciver Email" [(ngModel)]="this.AddRiciverForm.value.emailTo" required></p>
</div>
</div>
<div class="row">
<div class="col-sm-6 col-sm-offset-3">
<p><button class="btn btn-primary" type="submit" [disabled]="!transferForm.form.valid">Add</button> </p>
</div>
</div>
</div>
</form>
<button ng-click="AddEmailFunc()">add user</button>
Run Code Online (Sandbox Code Playgroud)
transfer.component.ts
import { Component, OnInit } from '@angular/core';
import { AuthService } from '../auth.service';
import { FormBuilder, FormGroup } from '@angular/forms';
import { Router } from '@angular/router';
import { Http } from '@angular/http';
import { PostsService …Run Code Online (Sandbox Code Playgroud) 该函数应该获取图像并将其转换为数据,然后将数据转换回图像。当我使用图像库中的图像或以横向模式拍摄照片时,效果很好。但是,当我以肖像模式拍摄照片时,图像在转换回图像时将会旋转和拉伸。有什么办法可以防止这种情况发生吗?
func pixelCalculator (){
let image = originalImage
let height = Int((image.size.height))
print(height)
let width = Int((image.size.width))
let bitsPerComponent = Int(8)
let bytesPerRow = 4 * width
let colorSpace = CGColorSpaceCreateDeviceRGB()
let rawData = UnsafeMutablePointer<RGBAPixel>.allocate(capacity: (width * height))
let bitmapInfo: UInt32 = CGBitmapInfo.byteOrder32Big.rawValue | CGImageAlphaInfo.premultipliedLast.rawValue
let CGPointZero = CGPoint(x: 0, y: 0)
let rect = CGRect(origin: CGPointZero, size: (image.size))
let imageContext = CGContext(data: rawData, width: width, height: height, bitsPerComponent: bitsPerComponent, bytesPerRow: bytesPerRow, space: colorSpace, bitmapInfo: bitmapInfo)
imageContext?.draw(image.cgImage!, in: rect)
let …Run Code Online (Sandbox Code Playgroud) 我有方法检查何时按下导航栏中的后退按钮,并且该方法返回到根页面,但由于某种原因,它只self.navigationController?.popToRootViewController(animated: true)返回到上一页。有谁知道按下导航栏后退按钮时如何返回根目录?
override func didMove(toParentViewController parent: UIViewController?) {
super.didMove(toParentViewController: parent)
if parent == nil{
self.navigationController?.popToRootViewController(animated: true)
}
}
Run Code Online (Sandbox Code Playgroud)
在这个问题中,他问如何使用什么方法来自定义后退按钮。在我的代码中,它能够检测用户何时按下后退按钮,并 self.navigationController?.popToRootViewController(animated: true)
假设将页面带回根页面,但是系统中存在某些内容阻止我的应用程序返回根页面。