Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
Node is saved as draft in My Content >> Draft
  • Add refresh to UITableView and load more data

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    Comment on it

    Hello friends

    If you are loading to a specific count data to a UITableView and you need to add more data on "refresh"(i.e PULL TO REFRESH) then I have some help here.

    Add protocol to Landing screen class and declare a method name : -(void)responseDict:(id)response tagValue:(int)tagValue;

    LandingScreenAgentClass

    -(void)gettingMoreDetail:(NSString *)make andStart:(NSString *)start andCount:(NSString *)count andModel:(NSString *)model andYear:(NSString *)year andReviewId:(NSString *)reviewId andladingArrayCount:(int)arrayCount delegate:(UIViewController<LandingScreenDelegate>*)del
    {
        tagValue=2;
        self.delegate = del;
    
    //    start=(NSString *)arrayCount;
    
        NSString *urlString=[NSString stringWithFormat:@"%@%@?make=%@&reviewId=%@&start=%d&count=%@",BASE&#95;URL&#95;FOR&#95;USER,BASE&#95;URL&#95;FOR&#95;FETCHING&#95;REVIEWS,@"dukati",reviewId,arrayCount,count];
        NSLog(@"url is %@",urlString);
        ASIHTTPRequest *request = [[ASIHTTPRequest alloc]initWithURL:[NSURL URLWithString:urlString]];
        [request setDelegate:self];
        [request setTimeOutSeconds:60];
    
        [request setDidFailSelector:@selector(setDidFailSelectorLanding:)];
        [request setDidFinishSelector:@selector(setDidFinishSelectorLanding:)];
        [request startAsynchronous];
    
    }
    

    ViewControllerImplementation

    pragma mark LandingScreenDelegates

    -(void)responseDict:(id)response tagValue:(int)tagValue
    {
    
                        NSDictionary *dict = (NSDictionary *)response;
    
    
                        NSLog(@"dictdict====landing========%@",dict);
    
                        NSDictionary *status=[dict objectForKeyWithNullCheck:@"status"];
                        NSString *statuscode = [status objectForKeyWithNullCheck:@"code"];
                        NSString *description =[status objectForKeyWithNullCheck:@"description"];
    
                        if ([statuscode isEqualToString:STATUS&#95;CODE]&&[description isEqualToString:STATUS&#95;DESCRIPTION])
                        {
    
                            NSArray *dictReview = [dict objectForKeyWithNullCheck:@"review"];
                            NSMutableArray *dictArrayDelegate=[NSMutableArray new];
                            for (NSDictionary *dictValue in dictReview)
                            {
                                ReviewModel *reviewModal=[[ReviewModel alloc]initWithDictionary:dictValue];
                                [dictArrayDelegate addObject:reviewModal];
    
                            }
                            NSLog(@"DICT ARRAY IS %@",dictArrayDelegate);
                            if (dictArray==nil) {
                                dictArray = [[NSMutableArray alloc]init];
                            }
                            [dictArray addObjectsFromArray:dictArrayDelegate];
    //                        dictArray = [[NSArray alloc]initWithArray:dictArrayDelegate];
    //                        [activityIndicator setHidden:YES];
                            [carTable reloadData];
                        }
                        else if([statuscode isEqualToString:STATUS&#95;FAILED])
                        {
                            [Utils showAlert:@"Messages" message:@"Nothing fetched"];
                        }
    
    
       atuscode isEqualToString:STATUS&#95;FAILED])
                {
                    [Utils showAlert:@"FAIL" message:@"Failed Hit"];
                }
    
                }
       }
    

    For making a pull to refresh you need to user Scroll view delegates

    - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
    {
    
        NSLog(@"cartablecobntentoffset%f",carTable.contentOffset.y);
    
        NSLog(@"scrollview frame %f",scrollView.frame.size.height);
    
        NSLog(@"MIXED %f",((carTable.contentSize.height+carTable.frame.size.height)-10));
    
        if (carTable.contentOffset.y>((carTable.contentSize.height+carTable.frame.size.height)-700))
        {
            [carTable setScrollEnabled:NO];
            [activityIndicator setHidden:YES];
    
            [activityIndicator startAnimating];
    
    
    
            NSLog(@"car table is %f",carTable.contentOffset.y);
            LandingScreenSeverAgent *land=[[LandingScreenSeverAgent alloc]init];
            [land gettingMoreDetail:@"Toyota" andStart:@"" andCount:@"10" andModel:@"" andYear:@"" andReviewId:@"" andladingArrayCount:dictArray.count delegate:self];
    
    
    
        }
        [carTable setScrollEnabled:YES];
    
        if (carTable.contentOffset.y<700) {
    //        [activityIndicator removeFromSuperview];
    //        [activityIndicator setHidden:YES];
            NSLog(@"less contemt off set");
        }
    
    
    }
    

    I hope this helps you.

    refresh table ios ios pulltorefresh

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: