UIScrollView で .txt ファイルの内容を表示するページを含む iPhone アプリを作成しました。何らかの理由で、プレーンなtxtファイルにより、Scrollviewが左右にわずかにパンできるようになります。上下のスクロールのみを確実にしたいのです。
本当にこれで助けが必要..
ありがとう
#import "ITFAQController.h"
#import "FTCoreTextView.h"
@implementation ITFAQController
- (NSString *)textForView {
NSString *path = [[NSBundle mainBundle] pathForResource:@"faq" ofType:@"txt"];
NSError *error;
return [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:&error];
}
/*- (id)init
{
self = [super init];
if (self) {
// Custom initialization
[self showLogoInNavBar:YES];
}
return self;
}
*/
#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];
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 330, (self.view.bounds.size.height - 90))];
[self.view addSubview:scrollView];
FTCoreTextView *ctView = [[FTCoreTextView alloc] initWithFrame:CGRectMake(10, 0, 300, scrollView.bounds.size.height)];
[ctView setText:[self textForView]];
FTCoreTextStyle *defaultStyle = [FTCoreTextStyle styleWithName:FTCoreTextTagDefault];
[defaultStyle setFont:kITDescriptionFont];
[defaultStyle setTextAlignment:FTCoreTextAlignementJustified];
[defaultStyle setParagraphInset:UIEdgeInsetsMake(5, 10, 0, 0)];
[ctView addStyle:defaultStyle];
FTCoreTextStyle *title = [FTCoreTextStyle styleWithName:@"title"];
[title setFont:kITTitleFont];
[title setColor:kITCellFontColor];
[title setParagraphInset:UIEdgeInsetsMake(10, 0, 5, 0)];
[ctView addStyle:title];
FTCoreTextStyle *bold = [FTCoreTextStyle styleWithName:@"bold"];
[bold setFont:[UIFont boldSystemFontOfSize:14]];
[ctView addStyle:bold];
FTCoreTextStyle *link = [FTCoreTextStyle styleWithName:FTCoreTextTagLink];
[link setColor:[UIColor blueColor]];
[ctView addStyle:link];
FTCoreTextStyle *bullets = [FTCoreTextStyle styleWithName:FTCoreTextTagBullet];
[bullets setBulletColor:kITCellFontColor];
[bullets setFont:kITItalicFont];
[bullets setParagraphInset:UIEdgeInsetsMake(0, 10, 0, 0)];
[ctView addStyle:bullets];
[ctView fitToSuggestedHeight];
[scrollView addSubview:ctView];
[scrollView setContentSize:[ctView suggestedSizeConstrainedToSize:CGSizeMake(scrollView.bounds.size.width, CGFLOAT_MAX)]];
//[ctView fitToSuggestedHeight];
//[ctView sizeToFit];
}
- (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