2012-02-08 151 views
0

我想添加一個UIScrollView到下面的代碼,但有點不確定,因爲它包含來自txt文件的內容。希望對此有所幫助。謝謝:)以編程方式添加uiscrollview

#import "AboutController.h" 


@implementation AboutController 

- (NSString *)textForView 
{ 
    NSString *path = [[NSBundle mainBundle] pathForResource:@"about" ofType:@"txt"]; 
    NSError *error; 
    return [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:&error]; 
} 

#pragma mark - View lifecycle 

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib. 
- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    [self showLogoInNavBar:YES]; 
} 

- (void)viewDidUnload 
{ 
    [super viewDidUnload]; 
    // Release any retained subviews of the main view. 
    // e.g. self.myOutlet = nil; 
} 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    // Return YES for supported orientations 
    return (interfaceOrientation == UIInterfaceOrientationPortrait); 
} 

@end 
+1

請你解釋一下a)你期望發生什麼,b)實際發生了什麼,c)你已經做了什麼來解決這個問題?這不是一個問題。 – 2012-02-08 01:04:37

+0

我希望能夠滾動頁面,簡單。目前內容不可滾動。謝謝 – CraigBellamy 2012-02-08 01:14:38

回答

0

在你:

- (void)loadView 
{ 
    CGRect scrollViewFrame = CGRectMake(0, 0, 320, 460); 
    UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:scrollViewFrame]; 
    [self.view addSubview:scrollView]; 
    CGSize scrollViewContentSize = CGSizeMake(640, 460); 
    [scrollView setContentSize:scrollViewContentSize]; 
} 

希望幫助!

+0

它似乎沒有做任何事情.. :( – CraigBellamy 2012-02-08 09:16:32

+0

嗯......你可以發佈你試過的代碼? – iProRage 2012-02-09 02:06:22

相關問題