Why won#39;t UIScrollView scroll fully after adding objects? Using storyboard, ARC, and Xcode 4.5.2(为什么添加对象后 UIScrollView 不会完全滚动?使用故事板、ARC 和 Xcode 4.5.2)
问题描述
所以,我知道我有类似的问题,但可能不准确(所以请不要标记我——只是警告我或其他什么).我已经搜索了几天来解决这个简单的问题.使用故事板、ARC 和 Xcode 4.5.2,我只需将一堆标签放在 UIScrollView 中并让它垂直滚动.我已经尝试过在 viewDidLoad、viewDidAppear 和 viewWillAppear 中设置帧大小和内容大小的多种组合,但无济于事.当里面没有任何东西时,滚动视图可以完美滚动,但是当我给它添加标签时,滚动只会滚动很短的部分.
So, I know there are similar questions to mine, but maybe not exact (so please don't mark me down -- just warn me or something). I have searched for days for the solution to this SIMPLE issue. Using storyboards, ARC, and Xcode 4.5.2, I simply need to put a bunch of labels inside a UIScrollView and have it scroll vertically. I've tried so many combinations of setting frame sizes and content sizes within viewDidLoad, viewDidAppear, and viewWillAppear, but to no avail. The scroll view scrolls perfectly when there's nothing inside of it, but when I add labels to it, the scrolling only scrolls a very short section.
注意:我需要使用自动布局,否则我的整个项目都会搞砸.
Note: I need to use auto layout, otherwise my whole project will get messed up.
这是我当前的代码...
Here's my current code...
.h 文件:
#import <UIKit/UIKit.h>
@interface MortgageRatesViewController : UIViewController <UIScrollViewDelegate, UIScrollViewAccessibilityDelegate>
- (IBAction)backButton:(id)sender;
@property (strong, nonatomic) IBOutlet UIView *mortgageView;
@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;
@end
.m 文件:
#import "MortgageRatesViewController.h"
@interface MortgageRatesViewController ()
@end
@implementation MortgageRatesViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
//-------------------------------------------------------
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"appBackgroundColor.png"]];
[self.scrollView setScrollEnabled:YES];
[self.scrollView setContentSize:CGSizeMake(0, 809)];
}
//---------------------------------------------------------------
//---------------------------------------------------------------
//-(void)viewWillAppear:(BOOL)animated{
//
//
// [super viewWillAppear:animated];
//
//
// [self.scrollView setFrame:CGRectMake(0, 0, 320, 808)];
//
//
/
本文标题为:为什么添加对象后 UIScrollView 不会完全滚动?使用
基础教程推荐
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01