小编dra*_*aur的帖子

使用UIScrollview的iOS Autolayout:为什么滚动视图的内容视图不会填充滚动视图?

以下代码(在viewDidLoad中调用)会导致完全红色的屏幕.我希望它是一个完全绿色的屏幕.它为什么是红色的?我怎么能把它全部变成绿色?

UIScrollView* scrollView = [UIScrollView new];
scrollView.translatesAutoresizingMaskIntoConstraints = NO;
scrollView.backgroundColor = [UIColor redColor];
[self.view addSubview:scrollView];

UIView* contentView = [UIView new];
contentView.translatesAutoresizingMaskIntoConstraints = NO;
contentView.backgroundColor = [UIColor greenColor];
[scrollView addSubview:contentView];

NSDictionary* viewDict = NSDictionaryOfVariableBindings(scrollView,contentView);

[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[scrollView]|" options:0 metrics:0 views:viewDict]];
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[scrollView]|" options:0 metrics:0 views:viewDict]];

[scrollView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[contentView]|" options:0 metrics:0 views:viewDict]];
[scrollView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[contentView]|" options:0 metrics:0 views:viewDict]];
Run Code Online (Sandbox Code Playgroud)

uiscrollview ios autolayout ios6

43
推荐指数
1
解决办法
4万
查看次数

在为UITableView设置动画时停止UITableViewCells动画

我正在为UITableView制作动画.我希望表视图像这样滑动打开:

http://www.youtube.com/watch?v=XIGJLbiRsXE

但是,它打开如下:

http://www.youtube.com/watch?v=UJUX-ILCB_0

注意表格单元格本身是如何制作动画的.我怎么能阻止这种情况发生?

我正在使用autolayout.因此代码如下:

[theView addSubview:theTable];
[theTable reloadData];
[theTable invalidateIntrinsicContentSize];
[UIView animateWithDuration:.33 animations:^{
    [theView layoutIfNeeded];
 }];
Run Code Online (Sandbox Code Playgroud)

其他细节,可能会或可能不重要:

  • 表视图的父级是scrollView

  • 我重写了表视图的intrinsicContentSize以返回表视图中所有单元格的高度,因此表视图不会滚动

  • 我在显示之前更改了表视图的数据源

uitableview uianimation ios autolayout

8
推荐指数
2
解决办法
2743
查看次数

如何检测iOS 8中键盘的高度是否发生了变化?

在iOS 8上,键盘可以达到不同的高度.当用户在键盘之间切换或更改当前键盘的高度时,我该如何检测?

uikeyboard ios ios8

5
推荐指数
1
解决办法
888
查看次数

4
推荐指数
1
解决办法
1486
查看次数