問題描述
所以,我知道我有類似的問題,但可能不準確(所以請不要標記我——只是警告我或其他什么).我已經搜索了幾天來解決這個簡單的問題.使用故事板、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)];
//
//
/
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!