Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 07-30-2010, 06:30 AM   #1 (permalink)
Registered Member
 
Join Date: Jul 2010
Location: Ukraine
Posts: 18
kenshin is on a distinguished road
Default add pages from buffer to scrollview when needed

Hello, everyone.

I work under PDFViewer project and need some advice.

so, i load PDF pages in buffer (max 8), then displays its in ScrollView. And now i need implement one thing that adds pages in buffer (if (pagesInBuffer - currentPage < step)) and delete pages from begining of array, if they are't needed. I implemented tihs in my project, but not all working right.

This is the code :

Code:
if(currentPoint.x == screenWidth){
		currentPage += 1;
		screenWidth += 768;
		[self loadScrollViewWithPage:currentPage];
		
		if(realLastPage - currentPage <= step){
			
			for(int i = 0; i < step; i++){
				[myPage loadViewForPage:page cycles:realLastPage + i append:YES filename:filename array:pageArray];

				NSLog(@"size of pageArray after adding elements: %d", [pageArray count]);
				
				[pageArray removeObjectsInRange:NSMakeRange(0, step)];
				NSLog(@"size of pageArray after deleting elements: %d", [pageArray count]);
			}
			realFirstPage += step;
		}
	}
	
	NSLog(@"currentPage: %d", currentPage);
what they are doing :
1. load page with page number.
2. if laspage - currentpage < step load 'step' pages in buffer array.
3. deleting first 2 pages from array.
4. incement out firstpage for displaying right view.

What i forgot to implement. What are not correct.
Maybe i must make scroll.content size bigger?

P.S. thanks
P.S. and sorry, if in text you found gramatic mistakes.

Last edited by kenshin; 07-30-2010 at 08:02 AM.
kenshin is offline   Reply With Quote
Old 07-30-2010, 02:21 PM   #2 (permalink)
Registered Member
 
Join Date: Jul 2010
Location: Ukraine
Posts: 18
kenshin is on a distinguished road
Default

really, no ideas?
kenshin is offline   Reply With Quote
Old 08-02-2010, 01:55 AM   #3 (permalink)
Registered Member
 
Join Date: Jul 2010
Location: Ukraine
Posts: 18
kenshin is on a distinguished road
Default

all of upper code are in :
Code:
 - (void) scrollViewDidScroll:(UIScrollView*) sender
maybe code has wrong location? maybe something else? Really need help with this.
kenshin is offline   Reply With Quote
Old 08-04-2010, 02:08 AM   #4 (permalink)
Registered Member
 
Join Date: Jul 2010
Location: Ukraine
Posts: 18
kenshin is on a distinguished road
Default

maybe this help, i have also methods:

Code:
- (void)layoutScrollImages
{
	UIImageView *view = nil;
	NSArray *subviews = [scroller subviews];
	
	// reposition all image subviews in a horizontal serial fashion
	CGFloat curXLocation = 0;
	for (view in subviews)
	{
		if ([view isKindOfClass:[UIImageView class]] && view.tag > 0)
		{
			CGRect frame = view.frame;
			frame.origin = CGPointMake(curXLocation, 0);
			view.frame = frame;
			
			curXLocation += (kScrollObjWidth);
			//NSLog(@"pages X loc: %f", curXLocation);
		} 
	}
	
	[scroller setContentSize:CGSizeMake(((pagesInBuffer - 1) * kScrollObjWidth), [scroller bounds].size.height)];
	
}

//load images to our scrollview
- (void) loadScrollViewWithPage:(int) page{
	
	NSAutoreleasePool *aPool = [[NSAutoreleasePool alloc] init];
	
	UIImage *image = [pageArray objectAtIndex:page];
	imageView = [[UIImageView alloc] initWithImage:image];
		
	CGRect rect = imageView.frame;
	rect.size.height = kScrollObjHeight;
	rect.size.width = kScrollObjWidth;
	imageView.frame = rect;
	imageView.tag = page;
	imageView.transform = CGAffineTransformMakeScale(1, -1);
	[scroller addSubview:imageView];
	[imageView release];

	[self performSelectorOnMainThread:@selector(backgroundLoadFinished) withObject:nil waitUntilDone:NO];
	[aPool release];
}

Last edited by kenshin; 08-04-2010 at 03:14 AM.
kenshin is offline   Reply With Quote
Old 08-05-2010, 04:37 AM   #5 (permalink)
Registered Member
 
Join Date: Jul 2010
Location: Ukraine
Posts: 18
kenshin is on a distinguished road
Default

really no one can't help with this?
kenshin is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 338
16 members and 322 guests
appservice, bignoggins, dermotos, Domele, EXOPTENDAELAX, guusleijsten, Hamad, heshiming, linkmx, mariano_donati, Objective Zero, Paul Slocum, Rudy, Sloshmonster, teebee74
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,653
Threads: 94,115
Posts: 402,888
Top Poster: BrianSlick (7,990)
Welcome to our newest member, ohmniac
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 10:47 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0