我在viewDidLoad中使用以下代码创建了一个UIView(其中'secondview'显然是UIView的名称):
secondview = [[UIView alloc] initWithFrame:self.view.frame];
[secondview setBackgroundColor: [UIColor yellowColor]];
secondview.translatesAutoresizingMaskIntoConstraints = NO;
[self.view addSubview:secondview];
Run Code Online (Sandbox Code Playgroud)
然后在viewDidAppear中我向此视图添加了约束:
NSLayoutConstraint *constraint = [NSLayoutConstraint constraintWithItem:secondview attribute:NSLayoutAttributeRight
relatedBy:NSLayoutRelationEqual
toItem:self.view
attribute:NSLayoutAttributeRight
multiplier:1.0f constant:-20.0f];
[self.view addConstraint:constraint];
Run Code Online (Sandbox Code Playgroud)
但是,约束不适用于视图(至少不是我能看到的).相反,视图似乎只是从屏幕上消失了.但是,如果约束代码被注释掉,则视图再次加载适当的帧(显然没有应用约束).将相同的约束应用于Button或ImageView时,约束将完美应用.这让我认为问题是因为创建View时'initWithFrame',因为按钮和ImageView实际上都不需要指定它的大小.
你的想法是什么?我该怎么办?
你如何UIScrollView在特定点停止?也就是说,设置UIScrollView用户后交互的最终位置?
具体来说,如何在水平方向上设置间隔UIScrollView,以便它只在这些点停止?
我希望我说的很清楚.
我有一个Web视图,可根据要求加载URL.但是,当此Web视图重新加载相同的URL时,内容不会更新,但仍保留在首次加载后的状态.我假设这是由于自动缓存?删除应用程序文档和数据可以刷新Web视图,但随后会再次出现问题.
基本上,通过使用相机应用程序的自定义叠加,我想要拍摄多个图像(在我的情况下为5),只需按一下"捕捉"按钮.
我理解以下代码:
- (void)takePicture:(id)sender
{
self.pictureButton.enabled = NO;
[self.delegate takePicture];
}
Run Code Online (Sandbox Code Playgroud)
导致拍摄单张图像.有一种方法可以在按下一个按钮后将此操作复制5次吗?实际上,这将实现类似"爆发"效果,就像在Camera + app中实现的那样.
ios ×4
xcode ×4
objective-c ×2
camera ×1
constraints ×1
iphone ×1
uiscrollview ×1
uiwebview ×1