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 09-12-2011, 09:23 PM   #1 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 74
diabolo is on a distinguished road
Default Load more cell Problem

Hi,
i need your help guys
i have Load more button with TableFooterView and when i scroll down to the last cell its Automatically load more cells to the table. so Its Working but there is kind of bug if i scroll down to the last cell and then immediately do it again (scroll up and down to the last cell) its called 2 times.

i need to find a way that even if i "play" with the last cell its called only once until the task is over and then enable it again.

i know that i need to use bool but i dont know how, where and when to do it...

Code:
viewDidLoad
Code:
//set tableview footer
    [[NSBundle mainBundle] loadNibNamed:@"ActivityIndicator-iPhone" owner:self options:nil];//this gets a new instance from the xib
    self.footerActivityIndicator=self.activityIndicator;
    [[self tableView] setTableFooterView:[self activityIndicatorView]];
Code:
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
	if (([scrollView contentOffset].y + scrollView.frame.size.height) == [scrollView contentSize].height) {
        NSLog(@"scrolled to bottom");
        [[self footerActivityIndicator] startAnimating];
                [self performSelector:@selector(stopAnimatingFooter) withObject:nil afterDelay:0.5];
        }  

        return;
	}
Code:
//stop the footer spinner
- (void) stopAnimatingFooter{
    //add the data
    [[self footerActivityIndicator] stopAnimating];
    [self addItemsToEndOfTableView];
    [[self tableView] reloadData];
}
Code:
- (void) addItemsToEndOfTableView{
    
    NSLog(@"addItemsToEndOfTableView");
    // Parse
	NSURL *feedURL = [NSURL URLWithString:@"http://gdata.youtube.com/feeds/api/users/RayWilliamJohnson/uploads?v=2&alt=rss&sort_field=added&start-index=21&max-results=20"];
	feedParser = [[MWFeedParser alloc] initWithFeedURL:feedURL];
	feedParser.delegate = self;
	feedParser.feedParseType = ParseTypeFull; // Parse feed info and all items
	feedParser.connectionType = ConnectionTypeAsynchronously;
	[feedParser parse];
    
    
    
}
diabolo is offline   Reply With Quote
Old 09-13-2011, 09:11 AM   #2 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 74
diabolo is on a distinguished road
Default

UP
diabolo is offline   Reply With Quote
Old 09-13-2011, 09:16 AM   #3 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
Join Date: Aug 2008
Location: Memphis, TN, USA
Age: 24
Posts: 3,983
smithdale87 is on a distinguished road
Send a message via AIM to smithdale87
Default

Just as you said, you can use a BOOL ivar. I'd name it something like "loadingItems". In your scrollViewDidScroll, just before you startAnimating, wrap that in an "if" statement, where you check if "loadingItems" == NO. If it equals YES, then you don't need to do anything because your items are already loading.

Now, in your addItemsToEnd... method, after you are done parsing, just set loadingItems = NO.
smithdale87 is offline   Reply With Quote
Old 09-13-2011, 10:12 AM   #4 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 74
diabolo is on a distinguished road
Default

finally its working thank you
diabolo is offline   Reply With Quote
Old 09-13-2011, 10:19 AM   #5 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
Join Date: Aug 2008
Location: Memphis, TN, USA
Age: 24
Posts: 3,983
smithdale87 is on a distinguished road
Send a message via AIM to smithdale87
Default

you're welcome
smithdale87 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: 405
9 members and 396 guests
7twenty7, Eclectic, eski, fiftysixty, JackReidy, teebee74, tim0504, UMAD, yuncarl28
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,672
Threads: 94,121
Posts: 402,904
Top Poster: BrianSlick (7,990)
Welcome to our newest member, yuncarl28
Powered by vBadvanced CMPS v3.1.0

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