这篇为通过button控制跳转到ViewControllerPUSH 一个QQ好友列表
来源:互联网 发布:如何写js脚本抢票 编辑:程序博客网 时间:2024/06/05 18:49
//
// ViewController2.h
// Tab bar controllre
//
// Created by 红珊瑚 on 15/5/25.
// Copyright (c) 2015年 红珊瑚. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface ViewController2 :UIViewController
@end
//
// ViewController2.m
// Tab bar controllre
//
// Created by 红珊瑚 on 15/5/25.
// Copyright (c) 2015年 红珊瑚. All rights reserved.
//
#import "ViewController2.h"
#import "ViewControllerPUSH.h"
@interface ViewController2 ()
@end
@implementation ViewController2
- (void)viewDidLoad {
[superviewDidLoad];
self.view.backgroundColor = [UIColororangeColor];
self.navigationItem.title =@"首页2";
//创建按钮
UIButton *button = [[UIButtonalloc] initWithFrame:CGRectMake(60,150, 80, 60)];
button.backgroundColor = [UIColorpurpleColor];
[button setTitle:@"push"forState:UIControlStateNormal];
[self.viewaddSubview:button];
//按钮的操作
[button addTarget:selfaction:@selector(pushToViewController:)forControlEvents:UIControlEventTouchUpInside];
}
-(void)pushToViewController:(UIButton*)button
{
//1.初始化“名人”的子视图控制器
ViewControllerPUSH *push1 = [[ViewControllerPUSHalloc] init];
//在push的时候隐藏底部的 bar
self.hidesBottomBarWhenPushed =YES;
//2.把push1视图控制器添加到导航视图控制器
[self.navigationControllerpushViewController:push1 animated:YES];
//在push的时候隐藏底部的 bar
self.hidesBottomBarWhenPushed =NO;
}
@end
//
// ViewControllerPUSH.h
// Tab bar controllre
//
// Created by 红珊瑚 on 15/5/26.
// Copyright (c) 2015年 红珊瑚. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface ViewControllerPUSH :UIViewController
@end
//
// ViewControllerPUSH.m
// Tab bar controllre
//
// Created by 红珊瑚 on 15/5/26.
// Copyright (c) 2015年 红珊瑚. All rights reserved.
//
#import "ViewControllerPUSH.h"
@interface ViewControllerPUSH ()<UITableViewDataSource,UITableViewDelegate>
{
NSArray *sectionArr;
NSArray *rowArr;
UITableView *TaVi;
NSMutableDictionary *showDic;
}
@end
@implementation ViewControllerPUSH
- (void)viewDidLoad {
[superviewDidLoad];
self.view.backgroundColor = [UIColorcolorWithRed:200/255.0
green:100/255.0
blue:143/255.0
alpha:1.0f];
self.navigationItem.title =@"QQ好友列表";
//初始化tableview
TaVi = [[UITableViewalloc] initWithFrame:self.view.bounds
style:UITableViewStyleGrouped];
TaVi.backgroundColor = [UIColorlightGrayColor];
TaVi.delegate =self;
TaVi.dataSource =self;
[self.viewaddSubview:TaVi];
//初始化sectionArr
sectionArr = [NSArrayarrayWithObjects:@"好友",@"家人",@"同学",@"陌生人",@"黑名单",nil];
rowArr = [NSArrayarrayWithObjects:@"张三",@"李四",@"王五",@"朱六",@"未命名",@"未命名",nil];
}
//添加代理方法
//1. 分组
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return [sectionArrcount];
}
//2. cell行数
- (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section
{
return [rowArrcount];
}
//3. cell行的高度
- (CGFloat)tableView:(UITableView *)tableView
heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([showDicobjectForKey:[NSStringstringWithFormat:@"%ld",indexPath.section]])
{
return 60;
}
return 0;
}
//4. section头部高度
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 50;
}
//5. 显示每个cell内容
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [[UITableViewCellalloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:nil];
// cell.selectionStyle = UITableViewCellStyleDefault;
//插图分离器
cell.separatorInset =UIEdgeInsetsZero;//边缘插入图为零
//剪辑到边界 *
cell.clipsToBounds =YES;
//给cell添加第几行,和添加每行内容
cell.textLabel.text = [NSStringstringWithFormat:@"第 %ld行: %@",indexPath.row +1,rowArr[indexPath.row]];
return cell;
}
//6. section头部显示的内容
- (UIView *)tableView:(UITableView *)tableView
viewForHeaderInSection:(NSInteger)section
{
UIView *headerView = [[UIViewalloc] initWithFrame:CGRectMake(0,0, 320, 30)];
headerView.backgroundColor = [UIColorpurpleColor];
//在UIView上创建一个UILabel用来显示分组名称
UILabel *Label = [[UILabelalloc] initWithFrame:CGRectMake(10,15, 300, 20)];
Label.textColor = [UIColororangeColor];
Label.text = [NSStringstringWithFormat:@"分组-第 %ld 组名称:%@",section +1,sectionArr[section]];
[headerViewaddSubview:Label];
//初始化手势识,单击的recognizer,收缩分组cell
UITapGestureRecognizer *singleRecognizer = [[UITapGestureRecognizeralloc] initWithTarget:self
action:@selector(singleTap:)];
//点击的次数=1;
singleRecognizer.numberOfTapsRequired =1;
//1个手指操作
[singleRecognizer setNumberOfTouchesRequired:1];
//添加一个手势监测,到视图
[headerViewaddGestureRecognizer:singleRecognizer];
headerView.tag = section;
return headerView;
}
//7.实现手势监听事件的方法
- (void)singleTap:(UITapGestureRecognizer *)recognizer
{
//获取点击的分组下标 tag;
NSInteger didSection = recognizer.view.tag;
NSString *key = [NSStringstringWithFormat:@"%ld",didSection];
//创建字典,判断该分组字典内键值key=tag的元素是否为“A”,如果是则展开,否则 收缩隐藏
if (!showDic)
{
showDic = [[NSMutableDictionaryalloc] init];
}
if (![showDicobjectForKey:key])
{
[showDicsetObject:@"A"forKey:key];
}
else
{
[showDicremoveObjectForKey:key];
}
//刷新当前tag所在的分组,实现展开收缩功能
[TaVireloadSections:[NSIndexSetindexSetWithIndex:didSection]
withRowAnimation:UITableViewRowAnimationFade];
}
@end
- 这篇为通过button控制跳转到ViewControllerPUSH 一个QQ好友列表
- Android app内部启动qq/跳转到QQ添加好友
- 转移QQ好友列表
- 实现QQ 好友列表
- 仿QQ好友列表
- QQ好友列表
- qq好友列表 模拟
- 山寨QQ好友列表
- 获取QQ好友列表
- 练习:QQ 好友列表
- QQ好友列表展示
- iOS开发UI篇—使用UItableview完成一个简单的QQ好友列表(一)
- iOS开发UI篇—使用UItableview完成一个简单的QQ好友列表(二)
- iOS开发UI篇—使用UItableview完成一个简单的QQ好友列表(一)
- iOS开发UI篇—使用UItableview完成一个简单的QQ好友列表(二)
- iOS开发UI篇—使用UItableview完成一个简单的QQ好友列表(一)
- iOS开发UI篇—使用UItableview完成一个简单的QQ好友列表(二)
- Python 最近因开发项目的需要,有一个需求,就是很多SNS网站都有的通过 Email地址 导入好友列表,不过这次要导入的不是Email 列表,而是QQ的好友列表。 实现方式: 通过goog
- linux下多网卡配置同网段IP的问题以及解决方法
- 我的博客
- Android入门第八篇之GridView(九宫图)
- hdu 1050
- netstat监控大量ESTABLISHED连接与Time_Wait连接问题
- 这篇为通过button控制跳转到ViewControllerPUSH 一个QQ好友列表
- Caffe中的优化方法
- Linux控制台版扫雷游戏
- Linux的IO性能监控工具iostat详解
- Android提高十六篇之使用NDK把彩图转换灰度图
- 华科图书馆项目总结
- 精确监听AbsListView滚动至底部
- 【Android】Android开发之IPC进程间通信-AIDL介绍及实例解析
- vmware虚拟机与主机的三种通信方式