我只是想在我的imgView上设置宽度和高度约束.我有以下代码:
UIImageView *imgView = [[UIImageView alloc] init];
imgView.center = self.view.center;
imgView.image = [UIImage imageNamed:@"favorites5-highlighted.png"];
imgView.contentMode = UIViewContentModeCenter;
[self.view addSubview:imgView];
// width constraint
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:[imgView(==100)]" options:0 metrics:nil views:NSDictionaryOfVariableBindings(imgView)]];
// height constraint
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[imgView(==100)]" options:0 metrics:nil views:NSDictionaryOfVariableBindings(imgView)]];
Run Code Online (Sandbox Code Playgroud)
我最终得到这个错误:无法同时满足约束.我抬起头来尝试添加:
imgView.translatesAutoresizingMaskIntoConstraints = NO;
Run Code Online (Sandbox Code Playgroud)
和
self.view.translatesAutoresizingMaskIntoConstraints = NO;
Run Code Online (Sandbox Code Playgroud)
编辑:
我只是想将imageView的宽度和高度设置为所需的属性.我第一次尝试使用
CGRect rect = CGRectMake(0, 0, 10, 10);
imgView.frame = rect;
Run Code Online (Sandbox Code Playgroud)
但没有改变
在iPhone中,是否可以编写"手机"应用程序.我想要做的是当另一条线上的人挂断时发出声音.
我只是向我的同事展示了我的代码,他提醒我使用现代的客观c语法.我觉得自己像个白痴,因为我不知道他的意思.我怎样才能转换:
NSUserDefaults *rankDate = [NSUserDefaults standardUserDefaults];
[rankDate setObject:self.date forKey:@"rankDate"];
[rankDate setObject:[NSNumber numberWithInteger:self.date.people] forKey:@"people"];
[rankDate synchronize];
Run Code Online (Sandbox Code Playgroud)
进入"现代客观c语法"?
多年来我一直这样做,从来没有听说过这种语法.我应该担心吗?