iPhone Pull Down Refresh like Tweetie

前端 未结 5 1542
梦如初夏
梦如初夏 2020-11-30 20:05

I am trying to find an example of placing an element above the Table View outside the normal scrollable region. How would I do this? An example would be what the Tweetie 2 a

5条回答
  •  爱一瞬间的悲伤
    2020-11-30 20:48

    Here what you can do with iOS 6 and later:

    - (void)viewDidLoad { 
        // other initialization
        self.refreshControl = [[UIRefreshControl alloc] init];
        [self.refreshControl addTarget:self
                                action:@selector(myRefresh)
                      forControlEvents:UIControlEventValueChanged];
    }
    

    Your refresh method:

    - (void)myRefresh {  
        // get refreshed data for table view
    }  
    

    You end refreshing in reloadData:

    - (void)reloadData {  
        [self.tableView reloadData];  
    
        // End the refreshing   
        if (self.refreshControl) {  
            [self.refreshControl endRefreshing];  
        }  
    }    
    

    Then you are all set!

提交回复
热议问题