文档章节

qq

宝玉姚玉宝
 宝玉姚玉宝
发布于 2016/05/16 08:30
字数 1491
阅读 35
收藏 0
点赞 2
评论 0
qq

AppDelegate.h AppDelegate.m

XiaoXiViewController.h XiaoXiViewController.m

HaoYouViewController.h HaoYouViewController.m

DongTaiViewController.h DongTaiViewController.m

TiaoViewController.h TiaoViewController.m TiaoViewController.xib

AppDelegate.h

#import <UIKit/UIKit.h> #import <CoreData/CoreData.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;

@property (readonly, strong, nonatomic) NSManagedObjectContext *managedObjectContext; @property (readonly, strong, nonatomic) NSManagedObjectModel *managedObjectModel; @property (readonly, strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator;

  • (void)saveContext;
  • (NSURL *)applicationDocumentsDirectory;

@end

AppDelegate.m

#import "AppDelegate.h" #import "XiaoXiViewController.h" #import "HaoYouViewController.h" #import "DongTaiViewController.h"

@interface AppDelegate ()

@end

@implementation AppDelegate

  • (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch.

    self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds]; XiaoXiViewController *xiao = [[XiaoXiViewController alloc]init]; UINavigationController *Nav = [[UINavigationController alloc]initWithRootViewController:xiao]; UITabBarItem *item = [[UITabBarItem alloc]initWithTitle:@"消息" image:[UIImage imageNamed:@"tab_recent_press@2x"] selectedImage:[UIImage imageNamed:@"tab_recent_press@2x"]]; Nav.tabBarItem = item;

    HaoYouViewController *hao = [[HaoYouViewController alloc]init]; UINavigationController *Nav1 = [[UINavigationController alloc]initWithRootViewController:hao]; UITabBarItem *item1 = [[UITabBarItem alloc]initWithTitle:@"好友" image:[UIImage imageNamed:@"tab_buddy_press@2x"] selectedImage:[UIImage imageNamed:@"tab_buddy_press@2x"]]; Nav1.tabBarItem = item1;

    DongTaiViewController *dong = [[DongTaiViewController alloc]init]; UINavigationController *Nav2 = [[UINavigationController alloc]initWithRootViewController:dong]; UITabBarItem *item2 = [[UITabBarItem alloc]initWithTitle:@"动态" image:[UIImage imageNamed:@"tab_qworld_press@2x"] selectedImage:[UIImage imageNamed:@"tab_qworld_press@2x"]]; Nav2.tabBarItem = item2;

    UITabBarController *tab = [[UITabBarController alloc]init]; tab.viewControllers = @[Nav,Nav1,Nav2];

    self.window.rootViewController = tab;

    [self.window makeKeyAndVisible];

    return YES; }

  • (void)applicationWillResignActive:(UIApplication *)application { // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. }

  • (void)applicationDidEnterBackground:(UIApplication *)application { // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. }

  • (void)applicationWillEnterForeground:(UIApplication *)application { // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. }

  • (void)applicationDidBecomeActive:(UIApplication *)application { // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. }

  • (void)applicationWillTerminate:(UIApplication *)application { // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. // Saves changes in the application's managed object context before the application terminates. [self saveContext]; }

#pragma mark - Core Data stack

@synthesize managedObjectContext = _managedObjectContext; @synthesize managedObjectModel = _managedObjectModel; @synthesize persistentStoreCoordinator = _persistentStoreCoordinator;

  • (NSURL *)applicationDocumentsDirectory { // The directory the application uses to store the Core Data store file. This code uses a directory named "---.QQ" in the application's documents directory. return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]; }

  • (NSManagedObjectModel *)managedObjectModel { // The managed object model for the application. It is a fatal error for the application not to be able to find and load its model. if (_managedObjectModel != nil) { return _managedObjectModel; } NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"QQ" withExtension:@"momd"]; _managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL]; return _managedObjectModel; }

  • (NSPersistentStoreCoordinator *)persistentStoreCoordinator { // The persistent store coordinator for the application. This implementation creates and returns a coordinator, having added the store for the application to it. if (_persistentStoreCoordinator != nil) { return _persistentStoreCoordinator; }

    // Create the coordinator and store

    _persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]]; NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"QQ.sqlite"]; NSError *error = nil; NSString *failureReason = @"There was an error creating or loading the application's saved data."; if (![_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&error]) { // Report any error we got. NSMutableDictionary *dict = [NSMutableDictionary dictionary]; dict[NSLocalizedDescriptionKey] = @"Failed to initialize the application's saved data"; dict[NSLocalizedFailureReasonErrorKey] = failureReason; dict[NSUnderlyingErrorKey] = error; error = [NSError errorWithDomain:@"YOUR_ERROR_DOMAIN" code:9999 userInfo:dict]; // Replace this with code to handle the error appropriately. // abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. NSLog(@"Unresolved error %@, %@", error, [error userInfo]); abort(); }

    return _persistentStoreCoordinator; }

  • (NSManagedObjectContext *)managedObjectContext { // Returns the managed object context for the application (which is already bound to the persistent store coordinator for the application.) if (_managedObjectContext != nil) { return _managedObjectContext; }

    NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator]; if (!coordinator) { return nil; } _managedObjectContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSMainQueueConcurrencyType]; [_managedObjectContext setPersistentStoreCoordinator:coordinator]; return _managedObjectContext; }

#pragma mark - Core Data Saving support

  • (void)saveContext { NSManagedObjectContext *managedObjectContext = self.managedObjectContext; if (managedObjectContext != nil) { NSError *error = nil; if ([managedObjectContext hasChanges] && ![managedObjectContext save:&error]) { // Replace this implementation with code to handle the error appropriately. // abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. NSLog(@"Unresolved error %@, %@", error, [error userInfo]); abort(); } } }

@end

XiaoXiViewController.h

#import <UIKit/UIKit.h>

@interface XiaoXiViewController : UIViewController

@end

XiaoXiViewController.m

#import "XiaoXiViewController.h" #import "TiaoViewController.h" @interface XiaoXiViewController ()<UITableViewDataSource,UITableViewDelegate,UISearchBarDelegate,UISearchResultsUpdating,UISearchBarDelegate> { UITableView *_table; NSArray *imgArr; NSArray *perArr; NSArray *arr; NSArray *subArr; UISearchBar *search; UISearchDisplayController *_display;

}

@end

@implementation XiaoXiViewController

  • (void)viewDidLoad { [super viewDidLoad];

    self.title = @"消息"; self.view.backgroundColor = [UIColor whiteColor];

    arr = @[@"信息",@"对话"]; UISegmentedControl *segCtrl = [[UISegmentedControl alloc]initWithItems:arr];

    segCtrl.layer.cornerRadius=6; segCtrl.layer.masksToBounds=YES;

    [segCtrl addTarget:self action:@selector(clickSeg:) forControlEvents:UIControlEventValueChanged];

    segCtrl.selectedSegmentIndex=0; self.navigationItem.titleView=segCtrl;

    UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeCustom]; [btn1 setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];

    btn1.frame=CGRectMake(10, 10, 40, 40);

    btn1.layer.cornerRadius=20; btn1.layer.masksToBounds=YES;

    UIBarButtonItem *l=[[UIBarButtonItem alloc]initWithCustomView:btn1]; self.navigationItem.leftBarButtonItem=l;

    UIBarButtonItem *r=[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(click1)]; // 添加右侧按钮 self.navigationItem.rightBarButtonItem=r; // 设置表格 _table=[[UITableView alloc]initWithFrame:CGRectMake(0,0,[UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height) style:UITableViewStylePlain]; _table.delegate=self; _table.dataSource=self; _table.rowHeight=60;

    perArr=@[@"小阿布",@"大白",@"陌陌",@"皮卡丘",@"丘比特",@"张百万",@"张有才",@"科比"]; imgArr=@[@"1.jpg",@"1.jpg",@"1.jpg",@"1.jpg",@"1.jpg",@"1.jpg",@"1.jpg",@"1.jpg"];

    subArr=@[@"大好时光",@"晴空万里",@"大好时光",@"晴空万里",@"大好时光",@"晴空万里",@"大好时光",@"晴空万里"];

    [self.view addSubview:_table]; //搜索条 search=[[UISearchBar alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 40)]; // 设置提示文字 search.placeholder=@"搜索"; // 设置 搜索框颜色 search.barTintColor=[UIColor colorWithRed:32.0/255 green:178.0/255 blue:170.0/255 alpha:0.25]; // 设置代理 search.delegate=self; // 初始化搜索控制器 _display=[[UISearchDisplayController alloc]initWithSearchBar:search contentsController:self];

    // 设置代理 _display.searchResultsDelegate=self; _display.searchResultsDataSource=self; // 给表格添加搜索 _table.tableHeaderView=search;

    }

  • (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 8; }

  • (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { // 有复用池时 static NSString *cellId=@"cellId"; UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:cellId]; if (!cell) { // UITableViewCellStyleSubtitle cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellId]; } // 设置主标题 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]]; // imageView的圆角 cell.imageView.layer.cornerRadius=30; cell.imageView.layer.masksToBounds=YES; // 时间按钮 UIButton *btntime=[UIButton buttonWithType:UIButtonTypeRoundedRect]; [btntime setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal]; btntime.frame=CGRectMake(200, 10, 100, 20); [btntime setTitle:@"05:20" forState:UIControlStateNormal]; btntime.alpha=0.6; cell.accessoryView=btntime;

    return cell; } -(void)click1 { UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"提示" message:@"添加好友" delegate:self cancelButtonTitle:@"确定" otherButtonTitles: nil]; alert.alertViewStyle=UIAlertViewStylePlainTextInput; [alert show];

}

//设置分段控件的方法 -(void)clickSeg:(UISegmentedControl *)ss { if (ss.selectedSegmentIndex==1) { // 隐藏 桌面 _table.hidden=YES;

    TiaoViewController *tiao = [[TiaoViewController alloc]init];
    [self.navigationController pushViewController:tiao animated:YES];
    
}else
{
    _table.hidden=NO;
}

} //点击单元格时触发的方法 -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { if (indexPath.row==0) { // 跳转到下个界面 TiaoViewController *jump=[[TiaoViewController alloc]init]; [self.navigationController pushViewController:jump animated:YES];

}

}

  • (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. }

/* #pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation

  • (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller. } */

@end

HaoYouViewController.m

#import "HaoYouViewController.h"

@interface HaoYouViewController ()

@end

@implementation HaoYouViewController

  • (void)viewDidLoad { [super viewDidLoad]; self.title = @"好友"; self.view.backgroundColor = [UIColor blueColor];

}

  • (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. }

/* #pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation

  • (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller. } */

@end

DongTaiViewController.m

#import "DongTaiViewController.h"

@interface DongTaiViewController ()

@end

@implementation DongTaiViewController

  • (void)viewDidLoad { [super viewDidLoad]; self.title = @"动态"; self.view.backgroundColor = [UIColor yellowColor]; }

  • (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. }

/* #pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation

  • (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller. } */

@end

© 著作权归作者所有

共有 人打赏支持
宝玉姚玉宝
粉丝 1
博文 6
码字总数 9560
作品 0
东城
高级程序员

暂无文章

Android 获取各大音乐平台的真实下载地址

废话 电脑使用谷歌浏览器或者QQ浏览器的时候。。。。。。。说不清楚,还是看图吧 大概意思就是,只要网页上需要播放,只要能播放并且开始播放,这个过程就肯定会请求到相关的音乐资源,然后就...

她叫我小渝
30分钟前
0
0
shell中的函数、shell中的数组、告警系统需求分析

shell中的函数 格式: 格式: function f_name() { command } 函数必须要放在最前面 示例1(用来打印参数) 示例2(用于定义加法) 示例3(用于显示IP) shell中的数组 shell中的数组1 定义数...

Zhouliang6
今天
2
0
用 Scikit-Learn 和 Pandas 学习线性回归

      对于想深入了解线性回归的童鞋,这里给出一个完整的例子,详细学完这个例子,对用scikit-learn来运行线性回归,评估模型不会有什么问题了。 1. 获取数据,定义问题     没有...

wangxuwei
今天
1
0
MAC安装MAVEN

一:下载maven压缩包(Zip或tar可选),解压压缩包 二:打开终端输入:vim ~/.bash_profile(如果找不到该文件新建一个:touch ./bash_profile) 三:输入i 四:输入maven环境变量配置 MAVEN_HO...

WALK_MAN
今天
0
0
33.iptables备份与恢复 firewalld的9个zone以及操作 service的操作

10.19 iptables规则备份和恢复 10.20 firewalld的9个zone 10.21 firewalld关于zone的操作 10.22 firewalld关于service的操作 10.19 iptables规则备份和恢复: ~1. 保存和备份iptables规则 ~2...

王鑫linux
今天
2
0
大数据教程(2.11):keeperalived+nginx高可用集群搭建教程

上一章节博主为大家介绍了目前大型互联网项目的系统架构体系,相信大家应该注意到其中很重要的一块知识nginx技术,在本节博主将为大家分享nginx的相关技术以及配置过程。 一、nginx相关概念 ...

em_aaron
今天
1
0
Apache Directory Studio连接Weblogic内置LDAP

OBIEE默认使用Weblogic内置LDAP管理用户及组。 要整理已存在的用户及组,此前办法是导出安全数据,文本编辑器打开认证文件,使用正则表达式获取用户及组的信息。 后来想到直接用Apache Dire...

wffger
今天
2
0
HFS

FS,它是一种上传文件的软件。 专为个人用户所设计的 HTTP 档案系统 - Http File Server,如果您觉得架设 FTP Server 太麻烦,那么这个软件可以提供您更方便的档案传输系统,下载后无须安装,...

garkey
今天
1
0
Java IO类库之BufferedInputStream

一、BufferedInputStream介绍 /** * A <code>BufferedInputStream</code> adds * functionality to another input stream-namely, * the ability to buffer the input and to * sup......

老韭菜
今天
0
0
STM 32 窗口看门狗

http://bbs.elecfans.com/jishu_805708_1_1.html https://blog.csdn.net/a1985831055/article/details/77404131...

whoisliang
昨天
1
0

没有更多内容

加载失败,请刷新页面

加载更多

下一页

返回顶部
顶部