CodingNet - Learning - 11
2016-07-14 20:51
302 查看
前面讲到FliterMenu遮罩层菜单的实现,现在我们试着点击上面列表的内容
会发现,很帅地换了一个显示,整个过程自然,简洁
但是问题是,并没有出现任何的容器类(Navigationcontroller, TabBarController )的跳转操作,怎么实现的?
这个时候我们就介绍一款老少咸宜的三方框架,大名鼎鼎的:iCarousel
我们讲项目中用到iCarousel的地方都标注出来:
// 点击TabBarItem并且传递到tableivew刷新
- (void)tabBarItemClicked{
[super tabBarItemClicked];
if (_myCarousel.currentItemView && [_myCarousel.currentItemView isKindOfClass:[ProjectListView class]]) {
ProjectListView *listView = (ProjectListView *)_myCarousel.currentItemView;
[listView tabBarItemClicked];
}
}
初始化icarousl,多注意初始化项
//添加myCarousel
_myCarousel = ({
iCarousel *icarousel = [[iCarousel alloc] init];
icarousel.dataSource = self;
icarousel.delegate = self;
icarousel.decelerationRate = 1.0;
icarousel.scrollSpeed = 1.0;
icarousel.type = iCarouselTypeLinear;
icarousel.pagingEnabled = YES;
icarousel.clipsToBounds = YES;
icarousel.bounceDistance = 0.2;
[self.view addSubview:icarousel];
[icarousel mas_makeConstraints:^(MASConstraintMaker *make) {
// make.left.right.bottom.equalTo(self.view);
// make.top.equalTo(self.view).offset(kMySegmentControl_Height);
make.edges.equalTo(self.view);
}];
icarousel;
});
利用clickBlock 和 iCarousel 的 scrollToItemAtIndex “绑定"起来
__weak typeof(_myCarousel) weakCarousel = _myCarousel;
//初始化过滤目录
_myFliterMenu = [[PopFliterMenu alloc] initWithFrame:CGRectMake(0, 64, kScreen_Width, kScreen_Height-64) items:nil];
// _myFliterMenu = [[PopFliterMenu alloc] initWithFrame:CGRectMake(0, 0, kScreen_Width, kScreen_Height) items:nil];
__weak typeof(self) weakSelf = self;
_myFliterMenu.clickBlock = ^(NSInteger pageIndex){
if (pageIndex==1000) {
[weakSelf goToProjectSquareVC];
}else
{
[weakSelf fliterBtnClose:TRUE];
[weakCarousel scrollToItemAtIndex:pageIndex animated:NO];
weakSelf.selectNum=pageIndex;
}
};
_myFliterMenu.closeBlock=^(){
[weakSelf closeFliter];
};
是否可以滚动
- (void)setIcarouselScrollEnabled:(BOOL)icarouselScrollEnabled{
_myCarousel.scrollEnabled = icarouselScrollEnabled;
}
将XTSegmentControl 和 iCarousel绑定起来
// __weak typeof(_myCarousel) weakCarousel = _myCarousel;
// 添加滑块
// _mySegmentControl = [[XTSegmentControl alloc] initWithFrame:CGRectMake(0, 0, kScreen_Width, kMySegmentControl_Height) Items:_segmentItems selectedBlock:^(NSInteger index) {
// if (index == _oldSelectedIndex) {
// return;
// }
// [weakCarousel scrollToItemAtIndex:index animated:NO];
// }];
// [self.view addSubview:_mySegmentControl];
iCarousel代理方法:
- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view{
Projects *curPros = [_myProjectsDict objectForKey:[NSNumber numberWithUnsignedInteger:index]];
if (!curPros) {
curPros = [self projectsWithIndex:index];
[_myProjectsDict setObject:curPros forKey:[NSNumber numberWithUnsignedInteger:index]];
}
ProjectListView *listView = (ProjectListView *)view;
if (listView) {
[listView setProjects:curPros];
}else{
__weak Project_RootViewController *weakSelf = self;
listView = [[ProjectListView alloc] initWithFrame:carousel.bounds projects:curPros block:^(Project *project) {
[weakSelf goToProject:project];
DebugLog(@"\n=====%@", project.name);
} tabBarHeight:CGRectGetHeight(self.rdv_tabBarController.tabBar.frame)];
listView.clickButtonBlock=^(EaseBlankPageType curType) {
switch (curType) {
case EaseBlankPageTypeProject_ALL:
case EaseBlankPageTypeProject_CREATE:
case EaseBlankPageTypeProject_JOIN:
[weakSelf goToNewProjectVC];
break;
case EaseBlankPageTypeProject_WATCHED:
case EaseBlankPageTypeProject_STARED:
[weakSelf goToProjectSquareVC];
break;
default:
break;
}
};
//使用新系列Cell样式
listView.useNewStyle=_useNewStyle;
}
[listView setSubScrollsToTop:(index == carousel.currentItemIndex)];
return listView;
}
如果iCarousel用得好,的的确确是个强大的东西!
会发现,很帅地换了一个显示,整个过程自然,简洁
但是问题是,并没有出现任何的容器类(Navigationcontroller, TabBarController )的跳转操作,怎么实现的?
这个时候我们就介绍一款老少咸宜的三方框架,大名鼎鼎的:iCarousel
我们讲项目中用到iCarousel的地方都标注出来:
// 点击TabBarItem并且传递到tableivew刷新
- (void)tabBarItemClicked{
[super tabBarItemClicked];
if (_myCarousel.currentItemView && [_myCarousel.currentItemView isKindOfClass:[ProjectListView class]]) {
ProjectListView *listView = (ProjectListView *)_myCarousel.currentItemView;
[listView tabBarItemClicked];
}
}
初始化icarousl,多注意初始化项
//添加myCarousel
_myCarousel = ({
iCarousel *icarousel = [[iCarousel alloc] init];
icarousel.dataSource = self;
icarousel.delegate = self;
icarousel.decelerationRate = 1.0;
icarousel.scrollSpeed = 1.0;
icarousel.type = iCarouselTypeLinear;
icarousel.pagingEnabled = YES;
icarousel.clipsToBounds = YES;
icarousel.bounceDistance = 0.2;
[self.view addSubview:icarousel];
[icarousel mas_makeConstraints:^(MASConstraintMaker *make) {
// make.left.right.bottom.equalTo(self.view);
// make.top.equalTo(self.view).offset(kMySegmentControl_Height);
make.edges.equalTo(self.view);
}];
icarousel;
});
利用clickBlock 和 iCarousel 的 scrollToItemAtIndex “绑定"起来
__weak typeof(_myCarousel) weakCarousel = _myCarousel;
//初始化过滤目录
_myFliterMenu = [[PopFliterMenu alloc] initWithFrame:CGRectMake(0, 64, kScreen_Width, kScreen_Height-64) items:nil];
// _myFliterMenu = [[PopFliterMenu alloc] initWithFrame:CGRectMake(0, 0, kScreen_Width, kScreen_Height) items:nil];
__weak typeof(self) weakSelf = self;
_myFliterMenu.clickBlock = ^(NSInteger pageIndex){
if (pageIndex==1000) {
[weakSelf goToProjectSquareVC];
}else
{
[weakSelf fliterBtnClose:TRUE];
[weakCarousel scrollToItemAtIndex:pageIndex animated:NO];
weakSelf.selectNum=pageIndex;
}
};
_myFliterMenu.closeBlock=^(){
[weakSelf closeFliter];
};
是否可以滚动
- (void)setIcarouselScrollEnabled:(BOOL)icarouselScrollEnabled{
_myCarousel.scrollEnabled = icarouselScrollEnabled;
}
将XTSegmentControl 和 iCarousel绑定起来
// __weak typeof(_myCarousel) weakCarousel = _myCarousel;
// 添加滑块
// _mySegmentControl = [[XTSegmentControl alloc] initWithFrame:CGRectMake(0, 0, kScreen_Width, kMySegmentControl_Height) Items:_segmentItems selectedBlock:^(NSInteger index) {
// if (index == _oldSelectedIndex) {
// return;
// }
// [weakCarousel scrollToItemAtIndex:index animated:NO];
// }];
// [self.view addSubview:_mySegmentControl];
iCarousel代理方法:
- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view{
Projects *curPros = [_myProjectsDict objectForKey:[NSNumber numberWithUnsignedInteger:index]];
if (!curPros) {
curPros = [self projectsWithIndex:index];
[_myProjectsDict setObject:curPros forKey:[NSNumber numberWithUnsignedInteger:index]];
}
ProjectListView *listView = (ProjectListView *)view;
if (listView) {
[listView setProjects:curPros];
}else{
__weak Project_RootViewController *weakSelf = self;
listView = [[ProjectListView alloc] initWithFrame:carousel.bounds projects:curPros block:^(Project *project) {
[weakSelf goToProject:project];
DebugLog(@"\n=====%@", project.name);
} tabBarHeight:CGRectGetHeight(self.rdv_tabBarController.tabBar.frame)];
listView.clickButtonBlock=^(EaseBlankPageType curType) {
switch (curType) {
case EaseBlankPageTypeProject_ALL:
case EaseBlankPageTypeProject_CREATE:
case EaseBlankPageTypeProject_JOIN:
[weakSelf goToNewProjectVC];
break;
case EaseBlankPageTypeProject_WATCHED:
case EaseBlankPageTypeProject_STARED:
[weakSelf goToProjectSquareVC];
break;
default:
break;
}
};
//使用新系列Cell样式
listView.useNewStyle=_useNewStyle;
}
[listView setSubScrollsToTop:(index == carousel.currentItemIndex)];
return listView;
}
如果iCarousel用得好,的的确确是个强大的东西!
相关文章推荐
- 峰回路转,Firefox 浏览器即将重返 iOS 平台
- 峰回路转,Firefox 浏览器即将重返 iOS 平台
- 不可修补的 iOS 漏洞可能导致 iPhone 4s 到 iPhone X 永久越狱
- iOS 12.4 系统遭黑客破解,漏洞危及数百万用户
- 每日安全资讯:NSO,一家专业入侵 iPhone 的神秘公司
- [转][源代码]Comex公布JailbreakMe 3.0源代码
- 讲解iOS开发中基本的定位功能实现
- iOS中定位当前位置坐标及转换为火星坐标的方法
- js判断客户端是iOS还是Android等移动终端的方法
- iOS应用开发中AFNetworking库的常用HTTP操作方法小结
- iOS应用中UISearchDisplayController搜索效果的用法
- iOS App开发中的UISegmentedControl分段组件用法总结
- IOS开发环境windows化攻略
- iOS应用中UITableView左滑自定义选项及批量删除的实现
- iOS中UIAlertView警告框组件的使用教程
- 浅析iOS应用开发中线程间的通信与线程安全问题
- iOS中的UIKeyboard键盘视图使用方法小结
- 检测iOS设备是否越狱的方法
- .net平台推送ios消息的实现方法