- 浏览: 265373 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
jimode2013:
thanks
UIPanGestureRecognizer学习笔记 -
白色蜻蜓:
- (void) loadView { //opaquevie ...
UIWebView中使用UIActivityIndicatorView
1、导入EGO框架,即附件中的EGO.ZIP中的两个类文件,以及一些相应的图片,在第二个tableview.zip文件中
2、我的.h文件
#import <UIKit/UIKit.h> #import "EGORefreshTableHeaderView.h" @interface QuanWenArt : UIViewController<UITableViewDelegate, UITableViewDataSource, EGORefreshTableHeaderDelegate,UIScrollViewDelegate> { // CGFloat height; EGORefreshTableHeaderView *_refreshHeaderView; BOOL _reloading; NSInteger cellHeight; } @property (nonatomic, retain) UITableView *table; @property (nonatomic ,retain) NSArray *data; @end
3.我的.m文件
#import "QuanWenArt.h" #import "AppDelegate.h" #import "MyNav.h" #import "JSON.h" @interface QuanWenArt () @end @implementation QuanWenArt @synthesize table = _table; @synthesize data = _data; -(void)dealloc { [super dealloc]; [_table release]; [_data release]; } - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { NSLog(@"----------------------------------------------------------"); self.navigationItem.title = @"文章"; // [self.navigationItem.backBarButtonItem setBackButtonBackgroundImage:[UIImage imageNamed:@"navbar.png"] // forState:UIControlStateNormal // barMetrics:UIBarMetricsDefault]; // //自定义返回按钮 UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom]; backButton.frame = CGRectMake(0, 0, 68, 31); backButton.backgroundColor = [UIColor clearColor]; [backButton setBackgroundImage:[UIImage imageNamed:@"btn_back.png"] forState:UIControlStateNormal]; [backButton addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside]; UIBarButtonItem *backBarButton = [[UIBarButtonItem alloc] initWithCustomView:backButton]; self.navigationItem.leftBarButtonItem = backBarButton; } return self; } - (void)viewDidLoad { [super viewDidLoad]; NSLog(@"这里是QuanWenArt类的viewDidLoad方法"); self.table = [[[UITableView alloc] initWithFrame: CGRectMake(0.0, 0.0, 320.0, 480.0) style: UITableViewStylePlain] autorelease]; self.table.delegate = self; self.table.dataSource = self; self.view = self.table; //初始化数据源 AppDelegate *delegate= [[UIApplication sharedApplication] delegate]; self.data = delegate.artsOfQWData; // NSLog(@"list is:%@",self.data); //增加下拉刷新加载数据 1; _refreshHeaderView=[[EGORefreshTableHeaderView alloc] initWithFrame: CGRectMake(0, 440, 320, 480)]; _refreshHeaderView.delegate=self; [self.table addSubview:_refreshHeaderView]; [_refreshHeaderView refreshLastUpdatedDate]; } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return self.data.count; } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: @"cell"]; //获取cell [ cell setBackgroundColor:[ UIColor blueColor ] ] ; //每次都要清空一下,否则cell中的内容会重叠 for (UIView *subview in [cell.contentView subviews]) [subview removeFromSuperview]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle: UITableViewCellStyleValue1 reuseIdentifier: @"cell"] autorelease]; } cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; //表格单元右侧的披露按钮 cell.selectionStyle = UITableViewCellSelectionStyleGray; int selectedIndex = [indexPath indexAtPosition: 1]; //获取行号 for (int i=0; i<self.data.count; i++) { if (i == selectedIndex) { NSDictionary *dict = [self.data objectAtIndex:i]; // NSString *idstr = [dict objectForKey:@"id"]; NSString *titlestr = [dict objectForKey:@"title"]; // NSString *authorstr = [dict objectForKey:@"author"]; // NSLog(@"id=%@,title=%@,author=%@",idstr,titlestr,authorstr); cell.textLabel.text = titlestr; cellHeight = cell.frame.size.height; break; } } return cell; } - (void)backAction { [self.navigationController popViewControllerAnimated:YES]; } //此方法是开始读取数据 增加下拉刷新加载数据 2; - (void)reloadTableViewDataSource { NSLog(@"start"); _reloading = YES; //打开线程,读取下一页数据 [NSThread detachNewThreadSelector:@selector(requestNext) toTarget:self withObject:nil]; } //增加下拉刷新加载数据 3; - (void)requestNext { NSAutoreleasePool * pool=[[NSAutoreleasePool alloc] init]; //请求下一页数据 NSMutableURLRequest *req = [[NSMutableURLRequest alloc] init]; NSString *strURL = [NSString stringWithFormat:@"http://192.168.1.49:8080/exz/xmlli?fl=exz-qw-tb&op=new&ps=10&pn=2"]; NSURL *connection = [[NSURL alloc] initWithString:strURL]; [req setURL:connection]; [req setHTTPMethod:@"GET"]; NSURLResponse *rep = nil; NSError *error = nil; NSData *data = [NSURLConnection sendSynchronousRequest:req returningResponse:&rep error:&error]; if(error) { NSLog(@"服务器请求失败"); }else { if (data) { NSLog(@"服务器请求成功"); NSString *jsonStr = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; NSArray *arr = [jsonStr JSONValue]; AppDelegate *delegate= [[UIApplication sharedApplication] delegate]; [delegate.artsOfQWData addObjectsFromArray:arr]; self.data = delegate.artsOfQWData; [jsonStr release]; } } [pool release]; //回到主线程跟新界面 [self performSelectorOnMainThread:@selector(dosomething) withObject:nil waitUntilDone:YES]; } //增加下拉刷新加载数据 4; -(void)dosomething { int count=[self.data count]; NSString *str1 = [NSString stringWithFormat:@"%d",count]; NSString *str2 = [NSString stringWithFormat:@"%d",self.table.contentSize.height]; NSLog(@"-->%@",str1); NSLog(@"-->%@",str2); // // if(100*count>2000) // { // // self.table.contentSize=CGSizeMake(320, 40*count); //设置显示上来加载那一块view的CGRECT _refreshHeaderView.frame=CGRectMake(0, cellHeight*count, 320, 480); // } [self.table reloadData]; [self performSelector:@selector(doneLoadingTableViewData) withObject:nil afterDelay:0]; } //此方法是结束读取数据 - (void)doneLoadingTableViewData{ // model should call this when its done loading _reloading = NO; [_refreshHeaderView egoRefreshScrollViewDataSourceDidFinishedLoading:self.table]; NSLog(@"end"); } #pragma mark - #pragma mark UIScrollViewDelegate Methods - (void)scrollViewDidScroll:(UIScrollView *)scrollView{ [_refreshHeaderView egoRefreshScrollViewDidScroll:self.table]; } - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{ [_refreshHeaderView egoRefreshScrollViewDidEndDragging:self.table]; } #pragma mark - #pragma mark EGORefreshTableHeaderDelegate Methods - (void)egoRefreshTableHeaderDidTriggerRefresh:(EGORefreshTableHeaderView*)view{ [self reloadTableViewDataSource]; //[self performSelector:@selector(doneLoadingTableViewData) withObject:nil afterDelay:0.5]; } - (BOOL)egoRefreshTableHeaderDataSourceIsLoading:(EGORefreshTableHeaderView*)view{ return _reloading; // should return if data source model is reloading } - (NSDate*)egoRefreshTableHeaderDataSourceLastUpdated:(EGORefreshTableHeaderView*)view{ return [NSDate date]; // should return date data source was last changed } - (void)viewDidUnload { [super viewDidUnload]; // Release any retained subviews of the main view. } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation == UIInterfaceOrientationPortrait); } @end
- EGO.zip (3.7 KB)
- 下载次数: 26
- TableView.zip (204 KB)
- 下载次数: 29
发表评论
-
EXC_BAD_ACCESS
2013-06-21 17:59 875EXC_BAD_ACCESS 这个错误,可以这么说,90%的 ... -
NSAssert
2013-06-08 09:55 946You can use NSAssert() to deb ... -
UIWebView中的图片用本地document目录中的
2013-04-28 14:34 0-(void)webViewDidStartLoad:(UI ... -
如何点击链接直接跳转到app store指定应用下载页面
2013-03-21 14:42 2729跳转到应用下载页面: NSString *str = [ ... -
ios面试题收集一(附基本答案)
2013-03-20 11:40 1413此份面试题包含40个题目,是现在网上能搜索到的一个比较热的一 ... -
IOS5.1.1完美越狱XCODE测试出现10004003的问题
2013-03-15 11:23 1101我的APP已经上线了,但是公司有几个越狱后IOS5.1.1 ... -
MKLocalSearch用法
2013-03-08 15:21 6707原文出处:http://phpadvocate.com/bl ... -
NSString-NSDate类型转换和CustomBar的总结
2012-12-21 09:53 1291如何将一个字符串@"2012-12-21" ... -
ios判断本地文件是否存在
2012-12-17 17:36 1128NSString *path = [[NSBundle ... -
UIWebView响应单机事件
2012-12-14 11:40 1087在UIViewController中,加入协议UIGes ... -
APP适配iphone5 and ihpone4
2012-12-09 13:22 1974首先加入Default-568@2x.png得开机图片 CG ... -
百度地图API(1)
2012-12-04 14:25 2408问题 2012-10-26 11:37:05. ... -
iOS常用控件尺寸大集合
2012-11-28 16:36 1758元素控件 尺寸(pts) Window(含状态栏) 320 x ... -
UIPanGestureRecognizer学习笔记
2012-11-27 14:59 17593好久没来写笔记了,原因很简单,最近一直坐java网站,没顾上学 ... -
发送邮件---iphone开发
2012-09-27 14:00 13461、导入MessageUI.framework包 2、引入头 ... -
nsarray倒序排序
2012-09-24 16:28 2287NSSortDescriptor *descripto ... -
UITextField限制输入类型
2012-09-05 17:37 7292限制只能输入特定的字 ... -
怎么把椭圆的UISearchBar改成圆角矩形?
2012-08-29 13:03 4597for (UIView *subview in sel ... -
uitableview出现重叠的处理办法
2012-08-24 10:45 698for (UIView *subview in ... -
XIB那点问题
2012-08-09 10:49 9411、运行错误: this class is not key ...
相关推荐
js+css,tab选项卡,每个选项可以上拉刷新数据,下拉加载更多
listview上拉加载下一页,下拉加载上一页共通处理。 首页header隐藏,末页footer隐藏。 效果图参照博文:listview上拉加载上一页 下拉加载下一页共通处理
android Listview下拉刷新 上拉(滑动分页)加载更多 高仿新浪微博下拉刷新,同时实现了滑动加载下一页
swift写的上拉加载、下拉刷新,支持继承uiscrollview的控件(uitableview,uicollectionview),修复在Xcode6.4 的bug
基于 UIScrollview 的带上拉加载下一页数据和下拉刷新的瀑布流demo。本Demo使用使用 UrlImageView 实现网络图片异步加载和 EGORefresh 实现刷新。[appcodes.org]
listview下拉刷新页面,上拉加载,可以修改成加载下一页。
使用Iscroll5.1.3 封装实现移动端页面的上拉,下拉刷新页面,ajax加载下一页
这是一个可以实现下拉刷新和自动加载下一页的ListView,下拉刷新使用Google的原生效果 当然,你也可以整合侧滑删除的功能 #About Me Hi,clever programmer!I feel very honored that you are interested in my ...
下拉刷新,滑动到底部自动加载的listview 最后把时候还有下一页传入进去
SimpleRefreshLayout 支持下拉刷新,上拉加载以及无更多;支持布局自定义;
主要为大家详细介绍了微信小程序实现列表下拉刷新上拉加载,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
小伙伴们在逛淘宝或者是各种app上,都可以看到这样的功能,下拉刷新和加载更多以及滑动删除,刷新,指刷洗之后使之变新,比喻突破旧的而创造出新的,比如在手机上浏览新闻的时候,使用下拉刷新的功能,我们可以第一...
联系人分页,滚动加载下一页,下拉刷新已加载联系人。
精确实现web页面顶部向下滑动刷新当前页面。底部向上滑动加载下一页内容。
代码如下:public class PullToLoadListView extends ListView implements OnScrollListener { private static final String TAG = PullToLoadListView.class.getSimpleName(); private static final int STATE_...
MJRefresh无感刷新 项目开发中用了MJRefres ...产品提出需求,希望列表往下拉能直接出现下一页的数据,不需要出现加载的动画和等待时间。于是着手看了一下MJRefresh的源码,发现其提供了无感刷新(自动刷新)的方法。
1、不需要下拉刷新也不需要上拉加载 [self setupEmpty:self.tableView]; [self setupRefresh:self.tableView option:ATRefreshNone]; [self headerRefreshing]; 2、下拉刷新 [self setupEmpty:self....
weixin_烩面 微信小程序——会面APP 原APP下载地址 ...公司项目,用来提供接口学习小程序开发。 开发样式比较丑陋。...1、下拉加载,无数据时候的处理。下拉一直会刷新下一页。4页无数据还是会i下拉刷新5页。 2、