Created
October 16, 2011 10:44
-
-
Save antonsukhonosenko/1290752 to your computer and use it in GitHub Desktop.
Laker framework - trying to add image to intermediate scrollView
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)initPageNumbersForPages:(int)count { | |
pageSpinners = [[NSMutableArray alloc] initWithCapacity:count]; | |
for (int i = 0; i < count; i++) { | |
// ****** Spinners | |
UIActivityIndicatorView *spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; | |
spinner.backgroundColor = [UIColor clearColor]; | |
CGRect frame = spinner.frame; | |
frame.origin.x = pageWidth * i + (pageWidth + frame.size.width) / 2 - 20; | |
frame.origin.y = (pageHeight + frame.size.height) / 2; | |
spinner.frame = frame; | |
[pageSpinners addObject:spinner]; | |
[[self scrollView] addSubview:spinner]; | |
[spinner release]; | |
// ****** Numbers | |
NSUInteger width = pageWidth * 0.6; | |
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(pageWidth * i + (pageWidth) / 2 - (width/2), pageHeight / 2 + 20, width, 100)]; | |
label.backgroundColor = [UIColor clearColor]; | |
label.textColor = [UIColor PAGE_NUMBERS_COLOR]; | |
label.alpha = PAGE_NUMBERS_ALPHA; | |
label.numberOfLines = 0; | |
label.lineBreakMode = UILineBreakModeWordWrap; | |
// NSString *labelText = [[NSString alloc] initWithFormat:@"%d", i + 1]; | |
// Read title tag -------- | |
// REGEXP for matching title | |
NSRegularExpression *titleMatcher = [NSRegularExpression regularExpressionWithPattern:@"<title>(.*)</title>" | |
options:NSRegularExpressionCaseInsensitive | |
error:NULL]; | |
// read the file content | |
NSString *fileContents = [NSString stringWithContentsOfFile:[self.pages objectAtIndex: i] encoding:NSUTF8StringEncoding error:NULL]; | |
// parse file | |
//NSArray *matches = [titleMatcher matchesInString:fileContents options:0 range:NSMakeRange(0, [fileContents length])]; | |
//NSString *numberOfMatches = [[NSNumber numberWithInteger:[matches count]] stringValue]; | |
//NSRange match = [[matches objectAtIndex:1] range]; | |
NSTextCheckingResult *matchResult = [titleMatcher firstMatchInString:fileContents options:0 range:NSMakeRange(0, [fileContents length])]; | |
NSRange match = [matchResult rangeAtIndex:1]; | |
//NSString *labelText = [@"Lade Inhalt…" stringByAppendingString:numberOfMatches]; | |
NSString *labelText = @"Loading…"; | |
if (! NSEqualRanges(match, NSMakeRange(NSNotFound, 0))) { | |
labelText = [@"Loading…\n" stringByAppendingString:[fileContents substringWithRange:match]]; | |
} | |
// Read title tag end -------- | |
// AS: Here goes image creation | |
UIImageView *tempImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"28.jpg"]]; | |
[[self scrollView] addSubview:tempImageView]; | |
[tempImageView release]; | |
// AS: End image creation | |
label.font = [UIFont fontWithName:@"Times New Roman" size:18.0]; | |
label.textAlignment = UITextAlignmentCenter; | |
label.text = labelText; | |
//label.backgroundColor = [UIColor redColor]; | |
//[labelText release]; | |
[[self scrollView] addSubview:label]; | |
[label release]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment