以编程方式添加 uiscrollview [英] add uiscrollview programmatically
本文介绍了以编程方式添加 uiscrollview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将 UIScrollView 添加到以下代码中,但有点不确定,因为它包含来自 txt 文件的内容.将不胜感激在这方面的一些帮助.谢谢:)
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
推荐答案
在您的:
- (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];
}
希望有帮助!!
这篇关于以编程方式添加 uiscrollview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文