[英]add uiscrollview programmatically
I am trying to add a UIScrollView to the following code but a little unsure as it contains content from a txt file. 我正在尝试将UIScrollView添加到以下代码,但是有点不确定,因为它包含来自txt文件的内容。 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
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!! 希望有帮助!!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.