我遇到了一个问题,在我成功将用户签到我的应用程序后,我希望得到该用户.我的问题是用户总是如此null.奇怪的是,我在其他地方使用完全相同的方法来成功获取当前用户.
作为.NET的新手,我不确定为什么它不适合我.
var result = await _signInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, lockoutOnFailure: true);
if (result.Succeeded)
{
EmailModel emailModel = new EmailModel {
toEmail = model.Email,
subject = " ",
message = " "
};
var user = await _userManager.GetUserAsync(HttpContext.User);
// user here is always null
await _emailService.SendTestEmail(emailModel, user);
return RedirectToLocal(returnUrl);
}
Run Code Online (Sandbox Code Playgroud) 我真的可以在这里帮忙.我花了几个小时试图找出如何比较CGPoint的值和图像的中心属性.我假设这两个值是x和y坐标的形式.以下是我写的代码.
-(void) jigsawCompleted:(CGPoint) newcenter {
if(image1.center == newcenter &&
image2.center == newcenter &&
image3.center == newcenter &&
image4.center == newcenter) {
NSLog(@"success");
}
}
.......
.......
//if current touch is inside the rectangle
if (CGRectContainsPoint(snapToRect, location)) {
touch.view.alpha = 1.0;
//make a point with the coords below
CGPoint newcenter = CGPointMake(78, 382);
//assign the center coords of the current touch to this newly created point
touch.view.center = newcenter;
[self jigsawCompleted:newcenter];
return;
} else {
touch.view.alpha = 0.3;
}
Run Code Online (Sandbox Code Playgroud)
当比较jigsawCompleted方法中的两个值时,我得到错误:二进制表达式的无效操作数('CGpoint'(又名'struct CGPoint')和'CGPoint'). …
我希望有更好的方法来实现以下目标.我正在创建一个拼图类型的应用程序,这是我正在使用的当前代码:
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
//location of current touch
CGPoint location = [touch locationInView:self.view];
if ([touch view] == img1) {
[self animateFirstTouch:img1 withLocation:location];
} else if ([touch view] == img2) {
[self animateFirstTouch:img2 withLocation:location];
} else if ([touch view] == img3) {
[self animateFirstTouch:img3 withLocation:location];
} else if ([touch view] == img4) {
[self animateFirstTouch:img4 withLocation:location];
} else if {
......
......
} else if ([touch view] == img40) {
[self animateFirstTouch:img40 withLocation:location]; …Run Code Online (Sandbox Code Playgroud) 我有一些代码,UIImageView当用户触摸图像时会导致旋转180度.不幸的是,当用户再次触摸它时,没有任何反应.我假设确定图像已经旋转了180度,这可能就是为什么它不再移动了.我如何解决这个问题,谢谢.
-(void) spinSun
{
[UIView animateWithDuration:2.0f animations:^{
imgSun.transform = CGAffineTransformMakeRotation(-3.142);
} completion:^(BOOL finished) {
}];
}
Run Code Online (Sandbox Code Playgroud) 我试图动画一些图像.这些图像在非视网膜iPad上运行良好,但它们的视网膜对应物很慢,并且动画不会以指定的速率循环.我正在使用的代码如下所示,每隔1/25秒调用一次.这种方法似乎表现得更好UIViewAnimations.
if (counter < 285) {
NSString *file = [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"Animation HD1.2 png sequence/file_HD1.2_%d", counter] ofType:@"png"];
@autoreleasepool {
UIImage *someImage = [UIImage imageWithContentsOfFile:file];
falling.image = someImage;
}
counter ++;
} else {
NSLog(@"Timer invalidated");
[timer invalidate];
timer = nil;
counter = 1;
}
}
Run Code Online (Sandbox Code Playgroud)
我意识到有很多图像,但对于帧数较少的动画,性能相同.就像我说的那样,非视网膜动画效果很好.上面的每张图片大约是90KB.我做错了什么或者这仅仅是iPad的限制?说实话,我觉得很难相信当它可以处理复杂的3D游戏时它无法处理这样的东西,所以我想我做错了什么.任何帮助,将不胜感激.
编辑1:
从下面的答案,我编辑了我的代码但无济于事.执行以下代码会导致设备崩溃.
在 viewDidLoad
NSString *fileName;
myArray = [[NSMutableArray alloc] init];
for(int i = 1; i < 285; i++) {
fileName = [NSString stringWithFormat:@"Animation HD1.2 png sequence/HD1.2_%d.png", i];
[myArray addObject:[UIImage imageNamed:fileName]]; …Run Code Online (Sandbox Code Playgroud) 在对a执行动画变换时,我遇到了一些异常行为UIImageView.下面方法中的代码使图像看起来像是从一侧到另一侧摇摆:
-(void) shakeAnimation
{
float degrees = 30; //the value in degrees
imgShake.autoresizingMask = UIViewAutoresizingNone;
[UIView animateWithDuration:0.20f delay:0 options:(UIViewAnimationOptionCurveLinear | UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionAutoreverse | UIViewAnimationOptionRepeat) animations:^{
imgShake.transform = CGAffineTransformMakeRotation(degrees*M_PI/180);
} completion:^(BOOL finished) {
imgShake.transform = CGAffineTransformMakeRotation(1*M_PI/180);
NSLog(@"Shake finished");
}];
}
Run Code Online (Sandbox Code Playgroud)
问题出在我调用方法的地方.如果我调用viewDidAppear动画中的方法似乎完美...但由于其他原因我需要调用它viewDidLoad.当我从viewDidLoad动画函数调用方法但不是以指定的速度调用时animateWithDuration.它可能要慢得多0.70f.有什么我可以在这里失踪?
这可能是我自己的2变化检测如何角的作品,但我本来期望,如果一个组件的误解ChangeDetectionStrategy设置为Checked,CheckOnce或Detached,那该组件是只检查时组件实例一次变化。它似乎不会那样发生。
import {Component, OnInit, ChangeDetectionStrategy} from 'angular2/core'
@Component({
selector: 'my-app',
providers: [],
template: `
<div>
<button
(click)="onClick($event)"
[class.thing]="hasThingClass()">Update</button>
</div>
`,
changeDetection:ChangeDetectionStrategy.CheckOnce,
styles: [`
.thing { background-color: red }
`]
})
export class App implements OnInit {
public hasThing:Boolean = false;
onClick() {
this.hasThing = !this.hasThing;
}
hasThingClass(e) {
return this.hasThing;
}
}
Run Code Online (Sandbox Code Playgroud)
单击时,我本来希望切换hasThing属性,但我不希望视图更新。碰巧,视图会更新。ChangeDetectionStrategy设置为Detached也时发生。
http://plnkr.co/edit/2hHdt2BDpj419Z32iPjJ?p=preview
我在这里缺少什么?究竟是什么导致视图更新?从我所见,无论我更新hasThing属性,无论值是否已更改,视图都会在单击时更新。
我在初始化一系列bool时遇到了很多问题.当使用NSLog我不断得到(null).我正在尝试设置piecesInPlace40个NO的可变数组.我试图改变setupArrayWithFalses以YES用于测试目的,并仍然得到(null).
BOOL setupArrayWithFalses = NO;
for (int i=0; i<40; i++) {
[piecesInPlace addObject:[NSNumber numberWithBool:setupArrayWithFalses]];
}
NSLog(@"Value of object: %@", [piecesInPlace objectAtIndex:0]);
Run Code Online (Sandbox Code Playgroud) 我需要navigate在路由器上调用方法时自定义URL的编码方式.
我知道我需要实现自己的版本UrlSerializer并编写自定义serialize方法.我的问题是,我希望改变的唯一方法是使用encode方法url_tree.
export function encode(s) {
return encodeURIComponent(s);
}
Run Code Online (Sandbox Code Playgroud)
https://github.com/angular/angular/blob/master/modules/@angular/router/src/url_tree.ts#L344
为了做到这一点,我需要将以下所有方法复制+粘贴url_tree到my中,CustomSerializer因为它们不会被导出:
serialize
serializeQueryParams
Pair
pairs
serializeSegment
encode
我看了这个答案,但它并没有完全解决我的问题,因为我想要除了encode方法之外的所有默认行为.
我在这里遗漏了什么或有更好的方法来解决这个问题吗?
我有一个Web应用程序从另一个域的页面上擦除数据.这个数据在一周的特定时间更新几次,比如在星期三和星期五下午2点.
我有一个JS函数,它从该页面中抓取特定数据并将其存储在数据库中.如何安排在特定时间调用此函数?
ios ×6
objective-c ×5
angular ×2
ipad ×2
iphone ×2
animation ×1
arrays ×1
asp.net ×1
asp.net-core ×1
boolean ×1
cgpoint ×1
image ×1
javascript ×1
jquery ×1
rotation ×1
touch ×1
uiimage ×1
uiimageview ×1