0

I am trying to add a UIScrollView to the following code but a little unsure as it contains content from a txt file. Would appreciate some help on this. Thanks :)

#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
X Slash
  • 4,133
  • 4
  • 27
  • 35
CraigBellamy
  • 27
  • 2
  • 11
  • 1
    Can you please explain a) what you expect to happen, b) what actually happens, and c) what you have done to try to fix the problem? This is not much of a question as is. – jscs Feb 08 '12 at 01:04
  • I want to be able to scroll the page, simple. At the moment the contents are not scrollable. Thanks – CraigBellamy Feb 08 '12 at 01:14
  • 1
    Possible duplicate of [How to create a UIScrollView Programmatically?](https://stackoverflow.com/questions/2998336/how-to-create-a-uiscrollview-programmatically) – Cœur Nov 22 '18 at 18:08

1 Answers1

0

In your:

- (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];
}

Hope that helps!!

iProRage
  • 424
  • 7
  • 19