在京东小金库安全吗存了几万,也一直连续15天都有收益,今天进去看没收益了,是啥情况?

在UITableView中识别左右滑动,实现上下翻页的功能_iOS开发_动态网站制作指南
在UITableView中识别左右滑动,实现上下翻页的功能
来源:人气:1043
目前有三种方案:
UIScrollView + UITableView。
实现方法,在UIScrollView中,加入UITableView即可
设置UIScrollView的代理和方法
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
int currentPostion = scrollView.contentOffset.x;
if (currentPostion - 0 & 50) {
NSLog(@"Scroll right now ");
else if (0 - currentPostion & 50)
NSLog(@"Scroll left now");
2.利用UISweGestureRecognizer&
原文地址:
-(void)viewDidLoad{
UISwipeGestureRecognizer *
recognizer = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(handleSwipeFrom:)];
[recognizer setDirection:(UISwipeGestureRecognizerDirectionRight)];
[[self view] addGestureRecognizer:recognizer];
recognizer = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(handleSwipeFrom:)];
[recognizer setDirection:(UISwipeGestureRecognizerDirectionLeft)];
[[self view] addGestureRecognizer:recognizer];
recognizer = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(handleSwipeFrom:)];
[recognizer setDirection:(UISwipeGestureRecognizerDirectionUp)];
[[self view] addGestureRecognizer:recognizer];
recognizer = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(handleSwipeFrom:)];
[recognizer setDirection:(UISwipeGestureRecognizerDirectionDown)];
[[self view] addGestureRecognizer:recognizer];
-(void)handleSwipeFrom:(UISwipeGestureRecognizer *)recognizer{
if(recognizer.direction==UISwipeGestureRecognizerDirectionDown) {
NSLog(@"swipe down");
//执行程序
if(recognizer.direction==UISwipeGestureRecognizerDirectionUp) {
NSLog(@"swipe up");
//执行程序
if(recognizer.direction==UISwipeGestureRecognizerDirectionLeft) {
NSLog(@"swipe left");
//执行程序
if(recognizer.direction==UISwipeGestureRecognizerDirectionRight) {
NSLog(@"swipe right");
//执行程序
原文地址:
UITableView 屏蔽了左右滑动事件. &通过重载的方式可以事件touch事件, 供开发者使用..
#import &UIKit/UIKit.h&
@otocol TouchTableViewDelegate &NSObject&
- (void)tableView:(UITableView *)tableView touchesBegin:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)tableView:(UITableView *)tableView touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)tableView:(UITableView *)tableView touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)tableView:(UITableView *)tableView touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
#import "TouchTableView.h"
@implementation TouchTableView
@synthesize touchDelegate = _touchD
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
[super touchesBegan:touches withEvent:event];
if ([_touchDelegate conformsToProtocol:@protocol(TouchTableViewDelegate)] &&
[_touchDelegate respondsToSelector:@selector(tableView:touchesBegin:withEvent:)])
[_touchDelegate tableView:self touchesBegin:touches withEvent:event];
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
[super touchesCancelled:touches withEvent:event];
if ([_touchDelegate conformsToProtocol:@protocol(TouchTableViewDelegate)] &&
[_touchDelegate respondsToSelector:@selector(tableView:touchesCancelled:withEvent:)])
[_touchDelegate tableView:self touchesCancelled:touches withEvent:event];
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
[super touchesEnded:touches withEvent:event];
if ([_touchDelegate conformsToProtocol:@protocol(TouchTableViewDelegate)] &&
[_touchDelegate respondsToSelector:@selector(tableView:touchesEnded:withEvent:)])
[_touchDelegate tableView:self touchesEnded:touches withEvent:event];
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
[super touchesMoved:touches withEvent:event];
if ([_touchDelegate conformsToProtocol:@protocol(TouchTableViewDelegate)] &&
[_touchDelegate respondsToSelector:@selector(tableView:touchesMoved:withEvent:)])
[_touchDelegate tableView:self touchesMoved:touches withEvent:event];
调用方法 :
1. 头文件中加入delegate
@interface MoneyViewCtl : UIViewController&UITableViewDataSource, UITableViewDelegate, SDWebDataDownloaderDelegate, EGORefreshTableHeaderDelegate, TouchTableViewDelegate&{
IBOutlet UISegmentedControl *_sigT
IBOutlet TouchTableView *_
&2. .m文件中设置好delegate
_tableview.touchDelegate =
&3. .m文件中实现如下事件&
#pragma mark - TouchTableViewDelegate lifecycle
- (void)tableView:(UITableView *)tableView touchesBegin:(NSSet *)touches withEvent:(UIEvent *)event{
NSLog(@"touchesBegin");
- (void)tableView:(UITableView *)tableView touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event{
NSLog(@"touchesCancelled");
- (void)tableView:(UITableView *)tableView touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
NSLog(@"touchesEnded");
- (void)tableView:(UITableView *)tableView touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
NSLog(@"touchesMoved");
优质网站模板主题 : 求救,如何在页面的任何地方上滑下滑都是对tableview的操作
级别: 新手上路
可可豆: 34 CB
威望: 34 点
在线时间: 86(时)
发自: Web Page
来源于&&分类
求救,如何在页面的任何地方上滑下滑都是对tableview的操作&&&
如何在页面的任何地方上滑下滑都是对tableview的操作就是在其他的空白页面,也可以对tableview进行上下滑操作。
级别: 侠客
UID: 537058
可可豆: 403 CB
威望: 342 点
在线时间: 265(时)
发自: Web Page
给你个思路,就是通过监听触摸事件来改变tableView的偏移量,需要注意的是空白区域偏移量如果超过了tableView的大小,要在结束事件设置条件约束。
在遇到问题的时候,我一般都会自己思考,最少半个钟把,这是我给自己最低的底线,要是一遇到问题就去问别人,首先这是对别人的不尊重,也是对自己的不负责。
级别: 侠客
UID: 537058
可可豆: 403 CB
威望: 342 点
在线时间: 265(时)
发自: Web Page
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{&&&&//取得一个触摸对象(对于多点触摸可能有多个对象)&&&&UITouch *touch=[touches anyObject];&&&&//NSLog(@&%@&,touch);&&&&&&&&//取得当前位置&&&&CGPoint current=[touch locationInView:self.view];&&&&//取得前一个位置&&&&CGPoint previous=[touch previousLocationInView:self.view];&&&&&&&&//移动前的中点位置&&&&CGPoint tableoffset = tableView.contentO&&&&//移动偏移量&&&&CGPoint offset=CGPointMake(0, previous.y-current.y);&& &&&&//重新设置新位置&&&&[tableView setContentOffset:CGPointMake(tableoffset.x, tableoffset.y+offset.y)];&&&&NSLog(@&UIViewController moving...&);}剩下的细节问题就交给你自己解决了,已经把关键问题解决了,其它也提示给你了。
在遇到问题的时候,我一般都会自己思考,最少半个钟把,这是我给自己最低的底线,要是一遇到问题就去问别人,首先这是对别人的不尊重,也是对自己的不负责。
级别: 新手上路
可可豆: 34 CB
威望: 34 点
在线时间: 86(时)
发自: Web Page
回 2楼(zeng先生) 的帖子
十分感谢帮助。谢谢了
关注本帖(如果有新回复会站内信通知您)
苹果公司现任CEO是谁?2字 正确答案:库克
发帖、回帖都会得到可观的积分奖励。
按"Ctrl+Enter"直接提交
关注CocoaChina
关注微信 每日推荐
扫一扫 浏览移动版本帖子已过去太久远了,不再提供回复功能。程序写累了,就来玩玩酷跑小游戏吧,嘿嘿。
雨松MOMO送你一首歌曲,嘿嘿。
Three20研究院之自定义TableView列表详解(二)
Three20研究院之自定义TableView列表详解(二)
围观9394次
编辑日期: 字体:
开始本教程之间首先简单的介绍一些Three20自身提供绘制列表的组件TTTableView,它继承与TableView将列表组件又封装了一次,封装了很多好看的列表样式。这部分内容比较简单并且官方已经封装至Three20项目包中的样例程序包中。Three20下载与安装配置环境,请阅读上一章博文。打开Three20文件夹,选择Samples-&TTCatalog项目并且开打它,所有相关列表的样式都写在
TableItemTestController类当中,如下图所示,大致的样式都在这里。
系统提供的在好,它都不可能完美的满足开发的需求,所以开发时还是有必要使用自定义列表的样式。自定义永远比较灵活程序员可以手动的去修改它们的样式,本篇文章将重点探讨Three20下自定义列表样式的使用。
开始创建一个新的IOS项目,然后将Three20添加至该项目中,这一步如果有朋友还不会请阅读上一篇文章。因为绘制列表需要使用TTTableView所以创建一个Controller类去继承TTTableViewController。
#import &Three20/Three20.h&#import "TableViewDataSource.h"&@interface MovieController : TTTableViewController{&}@end
在ViewDidLoad执行一些列表初始化的操作,这里值得注意的是self.tableView.allowsSelection = YES;这行代码非常重要,没有这行代码表示选中列表某元素时,该元素将没有选中时的颜色,通常IOS开发中点击列表后列表背景颜色会变成蓝色,使用系统的方法去绘制列表会默认allowsSelection=YES,自定义列表需要手动设置allowsSelection=YES。
在createModel方法中去创建列表,这个方法由系统自身调用,用来创建列表组件,我们需要重写dataSource组件,所有列表的资源都写在TableViewDataSource方法中。
didSelectObject方法用来处理列表中某个元素被选择后的事件,这里设置点击任意元素后将直接打开百度的页面,选择元素的ID是: indexPath.row,数据类型为整形。
1234567891011121314151617181920212223242526272829303132333435
#import "MovieController.h"#import "MenuController.m"#import "TableItem.h"#import "TableItemCell.h"#import "TableViewDataSource.h"@implementation MovieController- (void)viewDidLoad{&&&&[super viewDidLoad];&&&&&//标题栏内容&&&&self.title = @"雨松MOMO测试列表";&&&&//开启列表自定义高度&&&&self.variableHeightRows = YES;&&&&//开启列表点击事件&&&&self.tableView.allowsSelection = YES;&}&- (void)createModel{&&&&//开始创建列表 self.dataSource = [[[TableViewDataSource alloc] init] autorelease];}&- (void)didSelectObject:(id)object atIndexPath:(NSIndexPath*)indexPath{&& //点击列表中的某一项后打开网页&& TTNavigator* navigator = [TTNavigator navigator];&& [navigator openURLAction:[TTURLAction actionWithURLPath:@""]];&& //得到用户点击列表的ID&& NSLog(@"%d",indexPath.row);}&@end
列表资源类:
#import &Three20/Three20.h&&@interface TableViewDataSource : TTListDataSource&@end
在Init方法中去创建列表的资源,image0与image1为两张贴图。创建列表资源时将所有列表资源写入TableItem类中。这个类用来记录列表中的数据。在itemWithTitle方法中去初始化每条列表元素中的数据。这里的数据是列表每个元素的名称,贴图,背景颜色。
在tableView方法中开始绘制列表,列表中有多少元素这个方法将会执行几次,以循环的方式将列表中的数据全部绘制在屏幕当中。绘制元素的时用到了一个非常重要的类TableItemCell。这个类主要用于列表的绘制,它规定的列表的样式,然后去TableItem类中拿数据,最后以它的样式一层一层的绘制在屏幕当中。
123456789101112131415161718192021222324252627282930313233343536
#import "TableViewDataSource.h"#import "TableItem.h"#import "TableItemCell.h"&@implementation TableViewDataSource&- (id)init {&&&&&//创建列表资源 if (self = [super init]) {&&&&&&&&UIImage *image0 = [UIImage imageNamed:@"0.jpg"];&&&&&&&&UIImage *image1 = [UIImage imageNamed:@"1.jpg"];
self.items = [NSArray arrayWithObjects:&&&&&&&&&&&&&&&&&&&&&&[TableItem itemWithTitle:@"电影1" image:image0 backcolor:[UIColor redColor]],&&&&&&&&&&&&&&&&&&&&&&[TableItem itemWithTitle:@"电影2" image:image1 backcolor:[UIColor purpleColor]],&&&&&&&&&&&&&&&&&&&&&&[TableItem itemWithTitle:@"电影3" image:image0 backcolor:[UIColor redColor]],&&&&&&&&&&&&&&&&&&&&&&[TableItem itemWithTitle:@"电影4"&&image:image1 backcolor:[UIColor purpleColor]],&&&&&&&&&&&&&&&&&&&&&&[TableItem itemWithTitle:@"电影5"&&image:image0 backcolor:[UIColor redColor]],&&&&&&&&&&&&&&&&&&&&&&[TableItem itemWithTitle:@"电影6"&&image:image1 backcolor:[UIColor purpleColor]],&&&&&&&&&&&&&&&&&&&&&&nil]; } return self;}&- (Class)tableView:(UITableView*)tableView cellClassForObject:(id) object {&&&&//绘制列表& if ([object isKindOfClass:[TableItem class]]) {
return [TableItemCell class]; }& return [super tableView:tableView &&&& cellClassForObject:object];}&@end
下面是列表的资源类TableItem。
1234567891011121314151617181920
#import &Three20/Three20.h&&@interface TableItem : TTTableLinkedItem { //列表元素的文字&&&&NSString *_title;&&&&//列表元素的贴图&&&&UIImage *_image;&&&&//列表元素的背景颜色&&&&UIColor *_backcolor;}&@property (nonatomic, copy) NSString *title;@property (nonatomic, copy) UIImage *image;@property (nonatomic, copy) UIColor *backcolor;&//初始化赋值+ (id)itemWithTitle:(NSString *)title&&&&&&&&&&&&&&image:(UIImage *)image backcolor:(UIColor *) backcolor; &@end
初始化的方法为intemWithTitle,在这里接收TableViewDataSource方法中传进来每个列表元素的所有资源,资源包括:文字信息,贴图信息,背景颜色,然后将TableItem对象返回出去,由TableViewDataSource类开始绘制列表。
1234567891011121314151617181920212223242526272829303132333435363738
#import "TableItem.h"&@implementation TableItem&@synthesize title = _title,image = _image, backcolor = _backcolor;&+ (id)itemWithTitle:(NSString *)title&&&&&&&&&&&&&&image:(UIImage *)image backcolor:(UIColor *) backcolor {&&&&//初始化 TableItem *item = [[[self alloc] init] autorelease]; item.title = title;&&&&item.image = image;&&&&item.backcolor = backcolor; return item;}&- (id)init{ if (self = [super init])&&&&{
_title = nil;&&&&&&&&_image = nil;&&&&&&&&_backcolor = nil; }& return self;}&- (void)dealloc{&&&&[super dealloc]; TT_RELEASE_SAFELY(_title);&&&&TT_RELEASE_SAFELY(_image);&&&&TT_RELEASE_SAFELY(_backcolor);&}&@end
下面是列表的样式类TableItemCell。
1234567891011
#import &Three20/Three20.h&&@interface TableItemCell : TTTableLinkedItemCell { //元素的名称&&&&UILabel *_titleLabel;&&&&//元素的贴图&&&&UIImageView *_imageview;&&&}&@end
tableView方法中设置列表中每个元素的高度。
initWithStyle方法中初始化列表中元素,这里创建一个文本框与图片视图并且加入整个窗口当中。
layoutSubviews方法中设置元素组件的显示区域,元素组建的坐标都是相对坐标,相对于每个列表元素的左上角点。
setObject这个方法比较重要,循环绘制列表之前会在这里获取在列表中显示的数据,参数为当前列表元素中的数据,在这里拿到屏幕中显示的文字与贴图还有背景颜色,并且全部设置入窗口视图当中。
这个方法用于设置按钮选中后的颜色,这里设置按钮选中后的颜色为蓝色,也可以在这里修改颜色。
self.selectionStyle = UITableViewCellSelectionStyleB
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
#import "TableItemCell.h"#import "TableItem.h"@implementation TableItemCell&+ (CGFloat)tableView:(UITableView*)tableView rowHeightForObject:(id)item{&&&&//每个列表元素的高度 return 80.0;}&- (id)initWithStyle:(UITableViewCellStyle)style&&&&reuseIdentifier:(NSString*)identifier{&&&&//初始化列表 if (self = [super initWithStyle:UITableViewCellStyleValue2&&&&&&&&&&&&&&&&&&&&reuseIdentifier:identifier])&&&&{
_item = nil;&
_titleLabel = [[UILabel alloc] initWithFrame:CGRectZero];&&&&&&&&//将文本框加入窗口
[self.contentView addSubview:_titleLabel];&&&&&&&&&_imageview = [[UIImageView alloc] initWithFrame:CGRectZero];&&&&&&&&//将图片视图加入窗口&&&&&&&&[self.contentView addSubview:_imageview];& }& return self;}&- (void)dealloc{ TT_RELEASE_SAFELY(_titleLabel);&&&&TT_RELEASE_SAFELY(_imageview); [super dealloc];}&- (void)layoutSubviews { [super layoutSubviews];& //设置列表中的组件,并且组件的绘制区域&&&&[_imageview setFrame:CGRectMake(5,5,70,70)];& [_titleLabel setFrame:CGRectMake(100,0,100,20)];&}&- (id)object{ return _item;}&- (void)setObject:(id)object { if (_item != object) {
[super setObject:object];&&&&&&&&//拿到列表中的数据
TableItem *item = object;&&&&&&&&//绘制在屏幕中
[_titleLabel setText:item.title];&&&&&&&&[_titleLabel setBackgroundColor:item.backcolor];&&&&&&&&&[_imageview setImage:item.image];&&&&&&&&[_imageview setBackgroundColor:item.backcolor];&&&&&&&&//设置列表的背景颜色&&&&&&&&self.contentView.backgroundColor = item.backcolor;&&&&&&&&//设置列表的选中颜色&&&&&&&&self.selectionStyle=UITableViewCellSelectionStyleBlue; & }}@end
最后在重要的入口类中指定打开MovieController类。
123456789101112131415161718192021222324252627282930313233
#import "AppDelegate.h"#import "MovieController.h"@implementation AppDelegate&@synthesize window = _window;&- (void)dealloc{&&&&[_window release];&&&&[super dealloc];}&- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{&&&&&//创建导航条&&&&TTNavigator* navigator = [TTNavigator navigator];&&&&navigator.persistenceMode = TTNavigatorPersistenceModeAll;&&&&navigator.window = [[[UIWindow alloc] initWithFrame:TTScreenBounds()] autorelease]; &&&&&TTURLMap* map = navigator.URLMap;&&&&[map from:@"*" toViewController:[TTWebController class]];&&&&[map from:@"tt://MovieView" toSharedViewController:[MovieController class]];&&&&&&&if (![navigator restoreViewControllers])&&&&{&&&&&&&&[navigator openURLAction:[TTURLAction actionWithURLPath:@"tt://MovieView"]];&&&&}&&&&&&&return YES;}&@end
自定义列表中的元素已经映入我们眼帘,选中列表中某个元素后背景颜色为蓝色,点击后直接打开百度的网页。有了本章的知识,大家可以任意的使用Three20制作自定义列表啦。哇咔咔!!!!!
最后欢迎各位盆友可以和MOMO一起讨论Three20软件开发,如果你觉得看得不清楚,MOMO附带上本章的源码下载,希望大家可以一起学习 哈哈~。哇咔咔~ MOMO愿和 大家好好学习,大家一起进步哈~!!!
下载地址:
(下载后必需搭建three20环境成功后才能运行~ 因为three20为引用加载,所以程序路径都是我本机的请见谅!或者你可可以将你的Three20路径修改的和我一样就可以直接运行啦,我的路径是:User (用户) -& Share(共享)-&Three20)。
本文固定链接:
转载请注明:
雨松MOMO提醒您:亲,如果您觉得本文不错,快快将这篇文章分享出去吧 。另外请点击网站顶部彩色广告或者捐赠支持本站发展,谢谢!
作者:雨松MOMO
专注移动互联网,Unity3D游戏开发
如果您愿意花10块钱请我喝一杯咖啡的话,请用手机扫描二维码即可通过支付宝直接向我捐款哦。
您可能还会对这些文章感兴趣!

我要回帖

更多关于 京东小金库安全吗 的文章

 

随机推荐