我在我的 iOS 应用程序中使用 EGOTableViewPullRefresh 库。为了实现它,我不得不将原来的类从 UIViewController 的子类更改为 UITableViewController。这显然破坏了我存储数据的方式,例如在 NSMutableArray 中。
标题:
#import <UIKit/UIKit.h>
#import "EGORefreshTableHeaderView.h"
@interface PullViewController : UITableViewController <EGORefreshTableHeaderDelegate, UITableViewDelegate, UITableViewDataSource>{
NSArray *news;
NSMutableArray *data;
EGORefreshTableHeaderView *_refreshHeaderView;
// Reloading var should really be your tableviews datasource
// Putting it here for demo purposes
BOOL _reloading;
}
- (void)reloadTableViewDataSource;
- (void)doneLoadingTableViewData;
@end
执行:
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response{
data = [[NSMutableData alloc] init];
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)theData{
[data appendData:theData];
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection{
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
news = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
[self.tableView reloadData];
[DejalBezelActivityView removeViewAnimated:YES];
}