如何在 Xcode5 中使用 AutoLayout 制作 ScrollView

2022-11-03移动开发问题
5

本文介绍了如何在 Xcode5 中使用 AutoLayout 制作 ScrollView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

在使用情节提要的 Xcode 5 中,如何在启用自动布局的情况下制作一个完全可操作的垂直滚动滚动视图?
考虑到子视图有层次结构:

In Xcode 5 using storyboards how would one make a fully operational vertical scrolling scrollview, with AutoLayout ON?
Considering the subviews have hierarchy:

  1.UIView  
    2.UIScrollView
      3.UIView (lets call this UIDetailView to make things easier)

请从代码到约束具体到任何视图是否必须更小等.

Please be specific from code to constraints to wether any of the views HAS to be smaller etc.

推荐答案

这篇博文详细介绍了如何使用 UIScrollView 和 Autolayout ON,使用纯自动布局方法.请注意,博客文章中的所有约束都是通过情节提要定义的.

This blog post details how to use a UIScrollView with Autolayout ON, using a pure autolayout approach. Note though that all constraints in the blog post are defined through the Storyboard.

帖子中的方法假定以下层次结构:

The approach in the post assumes the following hierarchy:

1. View (main view of my UIViewController)
  2. Scroll View (UIScrollView)
     3. Container View (UIView)
       4. Content View (e.g. UIImageView)

我猜容器视图将是您的 UIDetailView,而内容视图将是您的 UIDetailView 中的任何 UIView.

I guess the Container View will be your UIDetailView, and the Content View will be any UIView inside your UIDetailView.

https://happyteamlabs.com/blog/ios-how-to-use-uiscrollview-with-auto-layout-pure-auto-layout/

这篇关于如何在 Xcode5 中使用 AutoLayout 制作 ScrollView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End
Xcode

相关推荐

Cocos2D + 仅禁用 Retina iPad 图形
Cocos2D + Disabling only Retina iPad Graphics(Cocos2D + 仅禁用 Retina iPad 图形)...
2024-08-12 移动开发问题
10

没有cocos2D的xcode iphone粒子
xcode iphone particles without cocos2D(没有cocos2D的xcode iphone粒子)...
2024-08-12 移动开发问题
4

Cocos2d 人像模式在 iPhone 上不起作用
Cocos2d portrait mode not working on iPhone(Cocos2d 人像模式在 iPhone 上不起作用)...
2024-08-12 移动开发问题
2

为什么 xcode 归档成功但创建一个空的 .xcarchive 文件?
Why does xcode archive succeed but create an empty .xcarchive file?(为什么 xcode 归档成功但创建一个空的 .xcarchive 文件?)...
2024-08-12 移动开发问题
2

OpenGL vs Cocos2d:选择什么?
OpenGL vs Cocos2d: What to choose?(OpenGL vs Cocos2d:选择什么?)...
2024-08-12 移动开发问题
6

移动一个精灵时所有精灵不可见
All Sprite not visible while moving one sprite(移动一个精灵时所有精灵不可见)...
2024-08-12 移动开发问题
6