qq界面

#import "OneViewController.h"
#import "ImgShowViewController.h"

@interface OneViewController ()<UITableViewDelegate,UITableViewDataSource>
{
    UITableView *table;
    UISearchBar *search;
    UISearchDisplayController *dis;
    NSArray *imgArr;
    NSArray *perArr;
    NSArray *arr;
    NSArray *subArr;
}
@end

@implementation OneViewController

-(void)viewDidLoad
{
    [super viewDidLoad];
    self.view.backgroundColor=[UIColor whiteColor];
    self.navigationController.navigationBar.backgroundColor=[UIColor redColor];
    
    table =[[UITableView alloc]initWithFrame:self.view.frame style:UITableViewStylePlain];
    table.dataSource=self;
    table.delegate=self;
    table.separatorColor =[UIColor greenColor];
    [self.view addSubview:table];
    
    arr =@[ @"信息",@"对话"];
    UISegmentedControl *seg =[[UISegmentedControl alloc]initWithItems:arr];
    seg.layer.cornerRadius=6;
    seg.layer.masksToBounds=YES;
    [seg addTarget:self action:@selector(selectSeg:) forControlEvents:UIControlEventValueChanged];
    seg.selectedSegmentIndex=0;
    self.navigationItem.titleView =seg;
    
    UIBarButtonItem *leftItem = [[UIBarButtonItem alloc]initWithTitle:@"嗖" style:UIBarButtonItemStylePlain target:self action:@selector(clickleftBar)];
    self.navigationItem.leftBarButtonItem=leftItem;
    
    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc]initWithTitle:@"撒" style:UIBarButtonItemStylePlain target:self action:@selector(addBar)];
    self.navigationItem.rightBarButtonItem=rightItem;

    search =[[UISearchBar alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 40)];
    search.placeholder =@"搜索";
    dis =[[UISearchDisplayController alloc]initWithSearchBar:search contentsController:self];
    dis.searchResultsDataSource=self;
    dis.searchResultsDelegate=self;
    table.tableHeaderView=search;
    
    perArr=@[@"小阿布",@"大白",@"陌陌",@"皮卡丘",@"丘比特",@"张百万",@"张有才",@"科比"];
    imgArr=@[@"1.jpg",@"1.jpg",@"1.jpg",@"1.jpg",@"1.jpg",@"1.jpg",@"1.jpg",@"1.jpg"];
    subArr=@[@"大好时光",@"晴空万里",@"大好时光",@"晴空万里",@"大好时光",@"晴空万里",@"大好时光",@"晴空万里"];
    
    [self.view addSubview:table];
    
}
-(void)selectSeg:(UISegmentedControl *)ss
{
    if (ss.selectedSegmentIndex ==1) {
        table.hidden =YES;
        ImgShowViewController *imgShow =[[ImgShowViewController alloc]init];
        [self.navigationController pushViewController:imgShow animated:YES];
    }else
    {
        table.hidden=NO;
    }
    
}
-(void)clickleftBar
{
}
-(void)addBar
{
    UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"提示" message:@"添加好友" delegate:self cancelButtonTitle:@"确定" otherButtonTitles: nil];
    alert.alertViewStyle=UIAlertViewStylePlainTextInput;
    [alert show];
    
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 8;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *str =@"s";
    UITableViewCell *cell =[tableView dequeueReusableCellWithIdentifier:str];
    if (cell==nil) {
        cell =[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:str];
    }
    cell.textLabel.text =perArr[indexPath.row];
    cell.textLabel.font =[UIFont systemFontOfSize:16];
    cell.textLabel.textColor =[UIColor redColor];
    //    设置副标题
    cell.detailTextLabel.text=subArr[indexPath.row];
    cell.detailTextLabel.font=[UIFont systemFontOfSize:12];
    cell.detailTextLabel.textColor=[UIColor grayColor];
    //    设置图片
    cell.imageView.image=[UIImage imageNamed:[imgArr objectAtIndex:indexPath.row]];
    cell.imageView.layer.cornerRadius=30;
    cell.imageView.layer.masksToBounds=YES;
    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    ImgShowViewController *imgShow =[[ImgShowViewController alloc]init];
    [self.navigationController pushViewController:imgShow animated:YES];
}

转载于:https://my.oschina.net/suyongchen/blog/675454

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值