- 浏览: 317037 次
- 性别:
- 来自: 杭州
最新评论
-
atgoingguoat:
R.drawable.icon是LOG图
android九宫格实现 -
atgoingguoat:
android:src="@drawable/ico ...
android九宫格实现 -
修博龙泉:
旋转view:
CGAffineTransform at ...
动画-图片旋转 -
修博龙泉:
阻尼效果图片:
CALayer *layer = self.i ...
动画-图片旋转 -
bei-jin-520:
color]sdfsdfsdf
android九宫格实现
#import "WTAlbumImVC.h"
#import "WTPullRefreshView.h"
#import "WTAlbumPicListCell.h"
#import "WTPictureDetailVC.h"
@interface WTAlbumImVC () <WTPullRefreshViewDelegate, WTPictureDetailVCDelegate>
// picture list view
@property (retain, nonatomic) IBOutlet UIView *picListView;
@property (retain, nonatomic) IBOutlet UITableView *picTableView;
@property (retain, nonatomic) WTPullRefreshView *picPullRefreshView;
// im view
@property (retain, nonatomic) IBOutlet UIView *imView;
// picture list view data source
@property (retain, nonatomic) NSMutableArray *picArray;
@property (assign, nonatomic) BOOL picHasMore;
@property (retain, nonatomic) NSString *picCursor;
// im view data source
@end
@implementation WTAlbumImVC
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (UIBarButtonItem*)createBackBarButton
{
//定制自己的风格的 UIBarButtonItem
UIImage* image= [UIImage imageNamed:@"back.png"];
UIImage* imagef = [UIImage imageNamed:@"back_focus.png"];
CGRect backframe= CGRectMake(0, 0, image.size.width, image.size.height);
UIButton* backButton= [UIButton buttonWithType:UIButtonTypeCustom];
backButton.frame = backframe;
[backButton setBackgroundImage:image forState:UIControlStateNormal];
[backButton setBackgroundImage:imagef forState:UIControlStateHighlighted];
[backButton addTarget:self action:@selector(onBackButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem* someBarButtonItem= [[[UIBarButtonItem alloc] initWithCustomView:backButton] autorelease];
return someBarButtonItem;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
self.navigationItem.title = _album.albumName;
UIViewController *rootVC = [self.navigationController.viewControllers objectAtIndex:0];
if (rootVC == self || _dismissWhenExit) {
self.navigationItem.leftBarButtonItem = [self createBackBarButton];
}
self.picPullRefreshView = [[[WTPullRefreshView alloc] initWithTableView:_picTableView refreshOn:YES loadMoreOn:NO] autorelease];
_picPullRefreshView.delegate = self;
if (!self.picArray) {
// first time load
self.picArray = [NSMutableArray arrayWithCapacity:100];
[_picPullRefreshView triggerPullRefresh];
}
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)dealloc {
[TMRequest cancelRequestsWithDelegate:self];
self.picListView = nil;
self.picTableView = nil;
self.picPullRefreshView = nil;
self.imView = nil;
self.picArray = nil;
self.picCursor = nil;
[super dealloc];
}
- (void)viewDidUnload {
self.picListView = nil;
self.picTableView = nil;
self.picPullRefreshView = nil;
self.imView = nil;
[super viewDidUnload];
}
#pragma mark - User Click Methods
- (void)onBackButtonClicked:(id)sender {
[self dismissModalViewControllerAnimated:YES];
}
- (void)onPictureClicked:(WTPicture *)aPicture {
WTPictureDetailVC *detailVC = [[[WTPictureDetailVC alloc] init] autorelease];
NSUInteger index = [_picArray indexOfObject:aPicture];
detailVC.hidesBottomBarWhenPushed = YES;
[detailVC setDisplayIndex:index inPictureArray:_picArray hasMore:_picHasMore cursor:_picCursor delegate:self];
[self.navigationController pushViewController:detailVC animated:YES];
}
#pragma mark - Network Methods
- (void)getPictureListSuccess:(TMRequest *)aRequest{
BOOL refresh = (aRequest.tag==1);
if (refresh) {
[_picArray removeAllObjects];
}
TMCursorArray *cursorArray = aRequest.result;
if (cursorArray.array) {
[_picArray addObjectsFromArray:cursorArray.array];
}
self.picHasMore = cursorArray.hasMore;
self.picCursor = cursorArray.cursor;
_picPullRefreshView.needLoadMoreData = cursorArray.hasMore;
[_picTableView reloadData];
[_picPullRefreshView didFinishLoadingSuccess:YES];
}
- (void)getPictureListFail:(TMRequest *)aRequest{
[_picPullRefreshView didFinishLoadingSuccess:NO];
}
- (void)getPictureListFromServerByRefresh:(BOOL)aRefresh {
TMRequest *request = [[WTAlbumService sharedInstance] getPictureListByAlbumId:_album.albumId cursor:aRefresh?nil:_picCursor];
[request setDelegate:self successSel:@selector(getPictureListSuccess:) failSel:@selector(getPictureListFail:)];
if (aRefresh) {
request.tag = 1;
}
[request runAsync];
}
#pragma mark - WTPictureDetailVC Delegate Methods
- (void)pictureDetailVC:(WTPictureDetailVC *)aVC
exitAtPicture:(WTPicture *)aPicture
inPictureArray:(NSArray *)anArray
hasMore:(BOOL)aHasMore
cursor:(NSString *)aCursor
{
if ([_picPullRefreshView isLoading]) {
// 正在加载或者刷新的话,取消请求,避免数据异常
[TMRequest cancelRequestsWithDelegate:self];
[_picPullRefreshView didFinishLoadingSuccess:NO];
}
if ([_picArray count] < [anArray count]) {
// more data loaded
[_picArray removeAllObjects];
[_picArray addObjectsFromArray:anArray];
self.picHasMore = aHasMore;
self.picCursor = aCursor;
_picPullRefreshView.needLoadMoreData = self.picHasMore;
[_picTableView reloadData];
}
int position = NSNotFound;
for (int i=0; i<[_picArray count]; i++) {
WTPicture *temp = [_picArray objectAtIndex:i];
if ([temp.picId isEqualToString:aPicture.picId]) {
position = i;
break;
}
}
if (position != NSNotFound) {
int picCount = position + 1;
int rowCount = picCount / 3;
int mod = picCount % 3;
if (mod > 0) {
rowCount++;
}
int rowIndex = rowCount-1;
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:rowIndex inSection:0];
[_picTableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:NO];
}
}
- (TMRequest *)pictureDetailVC:(WTPictureDetailVC *)aVC requestForLoadMoreWithCursor:(NSString *)aCursor {
return [[WTAlbumService sharedInstance] getPictureListByAlbumId:_album.albumId cursor:aCursor];
}
- (void)pictureDetailVC:(WTPictureDetailVC *)aVC didPictureDisplayed:(WTPicture *)aPicture {
NSUInteger count = [self.picArray indexOfObject:aPicture]+1; // 加1是因为计算在第几行的时候,是按照个数来算的
int rowCount = count / 3;
int mod = count % 3;
if (mod > 0) {
rowCount++;
}
int rowIndex = rowCount-1;
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:rowIndex inSection:0];
[_picTableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:NO];
}
#pragma mark - UITableView Delegate Methods
//指定每个分区中有多少行,默认为1
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
int row = [_picArray count] / 3;
int mod = [_picArray count] % 3;
if (mod > 0) {
row ++;
}
return row;
}
-(CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 105;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"WTAlbumPicListCell";
WTAlbumPicListCell *cell = (WTAlbumPicListCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if(cell == nil){
NSArray *nib = [[NSBundle mainBundle]loadNibNamed:@"WTAlbumPicListCell" owner:self options:nil];
cell = [nib objectAtIndex:0];
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
int index1 = indexPath.row * 3;
int index2 = indexPath.row * 3 + 1;
int index3 = indexPath.row * 3 + 2;
WTPicture *pic1 = [_picArray objectAtIndex:index1];
WTPicture *pic2 = nil;
if (index2 < [_picArray count]) {
pic2 = [_picArray objectAtIndex:index2];
}
WTPicture *pic3 = nil;
if (index3 < [_picArray count]) {
pic3 = [_picArray objectAtIndex:index3];
}
[cell setPic1:pic1 pic2:pic2 pic3:pic3];
cell.delegate = self;
return cell;
}
#pragma mark -
#pragma mark WTPullRefreshViewDelegate UIScrollViewDelegate Methods
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
if (scrollView == _picTableView) {
[_picPullRefreshView scrollViewDidScroll:scrollView];
}
}
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{
if (scrollView == _picTableView) {
[_picPullRefreshView scrollViewDidEndDragging:scrollView];
}
}
#pragma mark WTPullRefreshViewDelegate Methods
- (void)pullRefreshViewDidTriggerRefresh:(WTPullRefreshView *)aPullFreshView {
if (aPullFreshView == _picPullRefreshView) {
[self getPictureListFromServerByRefresh:YES];
}
}
- (void)pullRefreshViewDidTriggerLoadMore:(WTPullRefreshView *)aPullFreshView {
if (aPullFreshView == _picPullRefreshView) {
[self getPictureListFromServerByRefresh:NO];
}
}
@end
发表评论
-
CCMenu 与 CCMenuItem
2013-11-09 11:52 861引入#import "ccDeprecate ... -
抛物线的精灵
2013-11-08 15:04 820// 抛物线 //mSprite:需要做抛物线的精灵 ... -
卡马克卷轴算法
2013-11-05 15:35 2114念 这里使用简化的概念,精确的定义请参考计算机图形学中二维观察 ... -
git 大招
2013-11-04 19:54 1576Last login: Mon Nov 4 19:30:1 ... -
AVAudioRecorder MAV格式录音
2013-08-15 21:13 1206//录音设置 NSDictionary * ... -
uilable根据字符串长度变化
2013-08-01 15:18 912CGSize labelSize = [ ... -
ios 文本自动换行
2013-07-30 19:52 1052// //自动换行 // UILabel *l ... -
ios 文本框随着键盘高度变化而变化
2013-07-29 18:22 2264监听键盘高度变化 [[NSNotificationC ... -
IOS开发苹果官方Sample Code及下载地址
2013-07-11 11:17 1612在线浏览地址:https://developer.apple ... -
苹果推送通知服务(APNs)编程(转)
2013-06-07 11:19 1304iPhone 对于应用程序在后台运行有诸多限制(除非你越狱) ... -
cell 数据重复
2013-06-03 15:21 1040static NSString *CellIdentifi ... -
ios NSDate NSTring long 时间戳与字符串转换
2013-05-22 11:09 27002一,转化的方法为 NSString *timeS ... -
关于缺少各种framework出现的错误累结(转)
2013-05-16 16:47 1404博客分类: iosiPhone开发 iosiPhone开发 ... -
动画-图片旋转
2013-05-13 11:28 1455旋转: iv = [[UIImageView alloc] ... -
UINavicationController
2013-05-13 09:41 901如果楼主想要使用UINavigationController中 ... -
NSTimer-动态修改Interval的值
2013-05-06 09:38 900NSTimer使用例子: NSTimer *sh ... -
UIScrollView的属性总结
2013-04-27 10:00 941UIScrollView的属性总结 属性 作用 CGPoint ... -
单例设置
2013-04-27 09:51 800+ (RootScrollView *)shareIn ... -
颜色设置
2013-04-27 09:50 715[Globle colorFromHexRGB:@&quo ... -
翻转动画
2013-04-11 16:11 808CGContextRef context ...
相关推荐
"s2_h_fenye"这个压缩包可能包含了一个用于数据库分页的模板代码,适用于学习和实际项目中。 数据库分页通常涉及以下几个关键知识点: 1. **SQL查询**:分页查询通常通过SQL语句实现,利用`LIMIT`(MySQL)或`...
fenye.jsp代码,是为了实现分页功能,就是实现数据库信息与jsp相连接的数据的分页查看功能
使用struts2和hibernate实现oracle分页源文件,提供完整可以运行的源代码,运行环境myeclipse8.5、myeclipse2016,struts2 版本,hibernate3以上版本
本资料"sql-2008-fenye.zip_doc"包含了关于如何在SQL Server 2008中实现分页存储过程的详细信息,并且提供了一个转换为.doc格式的文档。 分页查询的基本概念是限制从数据库检索的数据量,通常用于Web应用中的表格或...
本项目“jquery-fenye.zip”是关于Java后端与jQuery前端结合实现的一个小型分页功能的示例。下面将详细阐述相关知识点。 首先,我们来看Java分页。在Java Web应用中,分页通常在服务端进行,因为这有助于减少前端的...
这个jar包太好了 真是神通啊,它封装了hibernate分页 请大家在项目中 用一下 挺好用的 我自己创建的名称:FenYe.jar 欢迎大家下载!!!!
fenye.css
jsp分页演示,带文档分析,sqlserver2005
在Java编程领域,分页是数据管理中一个非常重要的概念,特别是在处理大量数据时,为了提高用户体验和系统性能。分页允许用户逐步加载和查看数据,而不是一次性加载所有记录,这样可以减少内存消耗并加快页面加载速度...
标题中的"fenye"是一个关于分页的项目,它包含了一些模板工具类,方便开发者在后续的项目中直接复用。 该项目的核心是实现一个纯手工的分页工具类,这意味着没有依赖任何特定的库或框架,这在某些场景下特别有用,...
1. 首先,创建一个JavaBean类,例如`FenYe`,用于处理分页逻辑: ```java public class FenYe { private ResultSet CountTopicrs; private ResultSet Pagirs; private int intCountTopic; private int int...
//------------3${fenye.view}[按钮样式] ${fenye.viewb}[链接样式] </td></tr> ${fenye.view} 此时重载有几个方法: 控制器类: A. MyPager.getPager(List list,HttpServletRequest request); B.MyPager....
<form method="POST" action="fenye1.jsp"> 第页 共页 (intPage){%> href="fenye1.jsp?page=<%=intPage+1%>">下一页 </a><%}%> (intPage>1){%><a href="fenye1.jsp?page=<%=intPage-1%>">
1. HK_pilu_fenye.csv:可能代表香港的电力消耗或碳排放的分区数据,"fenye"可能表示分年度或分季度的数据。 2. HK_fenye.csv:可能包含香港的整体碳排放数据,同样可能是按时间序列划分的。 3. HK_strength_fenye....
数据集中的"HK_strength_fenye.csv"和"A_strength_fenye.csv"文件分别提供了港股和A股上市公司在不同年度的碳强度数据,便于比较不同公司的环境绩效。 再者,“碳披露”是指企业主动公开其温室气体排放信息的行为,...
1. **分页参数**:在`FenYe.java`中,可能会定义一些属性来存储分页所需的参数,如当前页码(currentPage)、每页记录数(pageSize)、总记录数(totalRecords)以及总页数(totalPages)。 2. **构造方法**:为了...
接下来,`fenye.js`和`gettab.js`是JavaScript文件,它们负责处理表格数据的加载、分页逻辑和用户交互。在`fenye.js`中,我们可以定义分页函数,例如: ```javascript function pagination(data, pageSize) { let ...
首先,我们来看第一个存储过程`[sq8reyoung].[fenye_num]`,它的主要目的是计算满足特定条件的数据总行数。这个存储过程接受两个参数:`@TableNames`(要查询的表名)和`@Filter`(查询条件)。如果`@Filter`为空,...
在本案例中,"page.tld"文件就是TLD文件,它定义了自定义标签"fenye"的相关信息,包括标签名、属性等。"fenye.jar"是包含了自定义标签处理类和相关资源的库文件,这个库需要被添加到项目的类路径中以便使用。 分页...
具体使用时,开发者需要在JSP页面中引入"TLD"文件,然后在适当位置插入自定义标签,例如`<fenye:pagination/>`,并设置必要的属性如当前页数、每页条目数等。自定义标签内部会根据这些属性进行计算,并生成相应的...