#import <UIKit/UIKit.h>
#import "ViewController.h"
#import "SixViewController.h"
//#import "ThreeViewController.h"
//#import "FourViewController.h"
//#import "FiveViewController.h"
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong ,nonatomic )ViewController * viewController ;
@property (strong ,nonatomic )SixViewController * sixViewController ;
//@property (strong ,nonatomic )ThreeViewController * threeViewController ;
//@property(nonatomic,strong)FourViewController *fourViewController;
//@property(nonatomic,strong)FiveViewController *fiveViewController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen]bounds]];
self.window.tintColor = [UIColor redColor];//设置点击后颜色为红色
self.window.backgroundColor = [UIColor whiteColor];
_viewController = [[ViewController alloc]init];
_sixViewController = [[SixViewController alloc]init];
// _threeViewController = [[ThreeViewController alloc]init];
// _fourViewController = [[FourViewController alloc]init];
// _fiveViewController = [[FiveViewController alloc]init];
_viewController.tabBarItem.title=@"首页";
_viewController.tabBarItem.image=[UIImage imageNamed:@"1"];
_sixViewController.tabBarItem.title=@"列表";
_sixViewController.tabBarItem.image=[UIImage imageNamed:@"2"];
// _threeViewController.tabBarItem.title=@"Three";
// _threeViewController.tabBarItem.image=[UIImage imageNamed:@"3"];
// _fourViewController.tabBarItem.title = @"Four";
// _fourViewController.tabBarItem.image = [UIImage imageNamed:@"4"];
// _fiveViewController.tabBarItem.title = @"Five";
// _fiveViewController.tabBarItem.image = [UIImage imageNamed:@"dada"];
UITabBarController *tabber = [[UITabBarController alloc]init];
tabber.viewControllers = @[_viewController,_sixViewController];
self.window.rootViewController = tabber;
return YES;
}
#import <UIKit/UIKit.h>
#import "SevenViewController.h"
#import "TwoViewController.h"
@interface ViewController : UIViewController
@property(nonatomic,strong)UIImageView *image;
@property(nonatomic,strong)UIImageView *imageI;
@property(nonatomic,strong)UIImageView *imageII;
@property(nonatomic,strong)UIImageView *imageDog;
@property(nonatomic,strong)UIButton *bigButton;
@property(nonatomic,strong)TwoViewController *TwoView;
@property(nonatomic,strong)UIButton *bigButton1;
@property(nonatomic,strong)UIButton *smallButton1;
@property(nonatomic,strong)SevenViewController *sevenView;
#import "ViewController.h"
#import "FourViewController.h"
@interface ViewController ()
@end
@implementation ViewController
-(void)viewDidAppear:(BOOL)animated{
NSLog(@"-----viewDidAppear-----");
NSUserDefaults *user=[NSUserDefaults standardUserDefaults];
NSString *userName=[user valueForKey:@"userName"];
if (userName != nil) {
// _bigButton.hidden = YES;
_smallButton1 = [[UIButton alloc]initWithFrame:CGRectMake(170, 450, 50, 50)];
[_smallButton1 setTitle:@"写" forState:UIControlStateNormal];
_smallButton1.backgroundColor = [UIColor grayColor];
_smallButton1.layer.borderWidth = 2;
_smallButton1.layer.cornerRadius = 5;
[_smallButton1 addTarget:self action:@selector(xie) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:_smallButton1];
}
}
#import <UIKit/UIKit.h>
#import "ThreeViewController.h"
#import "FourViewController.h"
@interface TwoViewController : UIViewController
@property(nonatomic,strong)UILabel *labelAccount;
@property(nonatomic,strong)UILabel *labelSecret;
@property(nonatomic,strong)UITextField *textAccount;
@property(nonatomic,strong)UITextField *textSecret;
@property(nonatomic,strong)UIButton *buttonEnter;
@property(nonatomic,strong)UIButton *buttonRegister;
@property(nonatomic,strong)ThreeViewController *threeView;
@property(nonatomic,strong)UILabel *label;
-(void)promptMessage:(NSString *)string;
@property(nonatomic,strong)FourViewController *fourView;
@end
#import "TwoViewController.h"
#import "Register.h"
#import "ViewController.h"
@interface TwoViewController ()
@end
@implementation TwoViewController
- (void)viewDidLoad {
[super viewDidLoad];
_labelAccount = [[UILabel alloc]initWithFrame:CGRectMake(16, 220, 34, 21)];
_labelSecret = [[UILabel alloc]initWithFrame:CGRectMake(16, 293, 34, 21)];
_textAccount = [[UITextField alloc]initWithFrame:CGRectMake(79, 217, 220, 30)];
_textSecret = [[UITextField alloc]initWithFrame:CGRectMake(79, 289, 220, 30)];
_buttonEnter = [[UIButton alloc]initWithFrame:CGRectMake(74, 380, 41, 30)];
_buttonRegister = [[UIButton alloc]initWithFrame:CGRectMake(243, 380, 46, 30)];
UIImageView *image = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 375, 156)];
image.image = [UIImage imageNamed:@"6"];
[_buttonEnter setTitle:@"登录" forState:UIControlStateNormal];
[_buttonEnter setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
_buttonEnter.backgroundColor = [UIColor grayColor];
_buttonEnter.layer.borderWidth = 2;
_buttonEnter.layer.cornerRadius = 5;
[_buttonRegister setTitle:@"注册" forState:UIControlStateNormal];
[_buttonRegister setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
_buttonRegister.backgroundColor = [UIColor grayColor];
_buttonRegister.layer.borderWidth = 2;
_buttonRegister.layer.cornerRadius = 5;
_labelAccount.text = @"账户";
_textAccount.layer.borderWidth = 1;
_textAccount.layer.borderColor = [UIColor blackColor].CGColor;
_textAccount.layer.cornerRadius = 9;
_labelSecret.text = @"密码";
_textSecret.layer.borderWidth = 1;
_textSecret.layer.borderColor = [UIColor blackColor].CGColor;
_textSecret.layer.cornerRadius = 9;
//提示框
_label = [[UILabel alloc]initWithFrame:CGRectMake(100, 335, 170, 28)];
[_buttonRegister addTarget:self action:@selector(Register) forControlEvents:UIControlEventTouchUpInside];
[_buttonEnter addTarget:self action:@selector(Enter) forControlEvents:(UIControlEventTouchUpInside)];
[self.view addSubview:_label];
[self.view addSubview:_textAccount];
[self.view addSubview:_textSecret];
[self.view addSubview:_labelAccount];
[self.view addSubview:_labelSecret];
[self.view addSubview:_buttonEnter];
[self.view addSubview:_buttonRegister];
[self.view addSubview:image];
}
-(void)promptMessage:(NSString *)string{
_label.text = string;
_label.textAlignment=NSTextAlignmentCenter;
_label.textColor=[UIColor redColor];
_label.layer.borderWidth=2;
_label.layer.borderColor=[[UIColor alloc]initWithRed:0.2 green:0.4 blue:0.7 alpha:0.2].CGColor;
_label.layer.cornerRadius=10;
}
-(void)Register{
_threeView=[[ThreeViewController alloc]init];
[self presentViewController:_threeView animated:YES completion:nil];
}
-(int)judgeWithText:(NSString *)textAccount andSecret:(NSString*)secret and:(Register *)data
{
NSMutableArray *array=[[NSMutableArray alloc]init];
array=[data showAccountInformation];
int flag=0;
for (int i=0; i<[array count]; i++) {
if ([textAccount isEqual: array[i][@"account"] ]) {
if ([secret isEqual:array[i][@"secret"]]) {
flag++;
}
}
}
return flag;
}
-(void)Enter
{
Register *data=[[Register alloc]init];
if ([self judgeWithText:_textAccount.text andSecret:_textSecret.text and:data]!=1) {
[self promptMessage:@"账号或密码错误"];
}
else
{
NSUserDefaults *user=[NSUserDefaults standardUserDefaults];
[user setValue:_textAccount.text forKey:@"userName"];
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"提示框" message:@"登录成功" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];
[self dismissViewControllerAnimated:NO completion:nil];
// _fourView = [[FourViewController alloc]init];
// [self presentViewController:_fourView animated:YES completion:nil];
}
}
#import <UIKit/UIKit.h>
#import "Register.h"
@class TwoViewController;
@interface ThreeViewController : UIViewController
@property(nonatomic,strong)UILabel *labelHead;
@property(nonatomic,strong)UILabel *labelName;
@property(nonatomic,strong)UILabel *labelAge;
@property(nonatomic,strong)UILabel *accountLabel;
@property(nonatomic,strong)UILabel *secretLabel;
@property(nonatomic,strong)UITextField *fieldName;
@property(nonatomic,strong)UITextField *fieldAge;
@property(nonatomic,strong)UITextField *accountField;
@property(nonatomic,strong)UITextField *secretField;
@property(nonatomic,strong)UIButton *registerButton;
@property(nonatomic,strong)UILabel *label;
-(void)promptMessage:(UILabel *)label and: (NSString *)message;
-(int)judgeWithText:(NSString *)text and:(Register *)data;
@property(nonatomic,strong)UIButton *backButton;
@end
implementation ThreeViewController
- (void)viewDidLoad {
[super viewDidLoad];
UIImageView *image = [[UIImageView alloc]initWithFrame:CGRectMake(0, 500, 382, 158)];
image.image = [UIImage imageNamed:@"6"];
_labelHead = [[UILabel alloc]initWithFrame:CGRectMake(142, 41, 69, 21)];
_labelName = [[UILabel alloc]initWithFrame:CGRectMake(40, 102, 34, 21)];
_labelAge = [[UILabel alloc]initWithFrame:CGRectMake(40, 182, 34, 21)];
_accountLabel = [[UILabel alloc]initWithFrame:CGRectMake(40, 258, 34, 21)];
_secretLabel = [[UILabel alloc]initWithFrame:CGRectMake(40, 337, 34, 21)];
_fieldName = [[UITextField alloc]initWithFrame:CGRectMake(104, 99, 209, 30)];
_fieldAge = [[UITextField alloc]initWithFrame:CGRectMake(104, 178, 209, 30)];
_accountField = [[UITextField alloc]initWithFrame:CGRectMake(104, 254, 209, 30)];
_secretField = [[UITextField alloc]initWithFrame:CGRectMake(104, 333, 209, 30)];
_registerButton = [[UIButton alloc]initWithFrame:CGRectMake(168, 436, 39, 30)];
_backButton = [[UIButton alloc]initWithFrame:CGRectMake(5, 50, 46, 30)];
[_registerButton setTitle:@"注册" forState:UIControlStateNormal];
[_registerButton setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
_registerButton.backgroundColor = [UIColor grayColor];
_registerButton.layer.borderWidth = 2;
_registerButton.layer.cornerRadius = 5;
[_backButton setTitle:@"back" forState:UIControlStateNormal];
[_backButton setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
_backButton.backgroundColor = [UIColor grayColor];
_backButton.layer.borderWidth = 2;
_backButton.layer.cornerRadius = 5;
[_backButton addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
_labelHead.text = @"注册信息";
_labelName.text = @"姓名";
_labelAge.text = @"年龄";
_accountLabel.text = @"账户";
_secretLabel.text = @"密码";
_fieldName.layer.borderWidth = 1;
_fieldName.layer.borderColor = [UIColor blackColor].CGColor;
_fieldName.layer.cornerRadius = 9;
_fieldAge.layer.borderWidth = 1;
_fieldAge.layer.borderColor = [UIColor blackColor].CGColor;
_fieldAge.layer.cornerRadius = 9;
_accountField.layer.borderWidth = 1;
_accountField.layer.borderColor = [UIColor blackColor].CGColor;
_accountField.layer.cornerRadius = 9;
_secretField.layer.borderWidth = 1;
_secretField.layer.borderColor = [UIColor blackColor].CGColor;
_secretField.layer.cornerRadius = 9;
_fieldName.placeholder = @"请输入真实姓名";
_fieldAge.placeholder = @"请输入真实年龄";
_accountField.placeholder = @"请输入账户名";
_secretField.placeholder = @"请输入密码";
_label=[[UILabel alloc]initWithFrame:CGRectMake(120, 370, 170, 28)];
[self.view addSubview:_label];
[_registerButton addTarget:self action:@selector(clickRegister) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:_labelHead];
[self.view addSubview:_labelName];
[self.view addSubview:_labelAge];
[self.view addSubview:_accountLabel];
[self.view addSubview:_secretLabel];
[self.view addSubview:_fieldName];
[self.view addSubview:_fieldAge];
[self.view addSubview:_accountField];
[self.view addSubview:_secretField];
[self.view addSubview:_registerButton];
[self.view addSubview:_backButton];
[self.view addSubview:image];
}
-(void)promptMessage:(UILabel *)label and: (NSString *)message
{
label.text=message;
label.textAlignment=NSTextAlignmentCenter;
label.textColor=[UIColor redColor];
label.layer.borderWidth=2;
label.layer.borderColor=[[UIColor alloc]initWithRed:0.2 green:0.4 blue:0.7 alpha:0.2].CGColor;
label.layer.cornerRadius=10;
}
-(int)judgeWithText:(NSString *)text and:(Register *)data
{
NSMutableArray *array=[[NSMutableArray alloc]init];
array=[data showAccountInformation];
int flag=0;
for (int i=0; i<[array count]; i++) {
if ([text isEqual: array[i][@"content"] ]) {
flag++;
}
}
return flag;
}
#pragma 注册账号
-(void)clickRegister
{
Register *addData=[[Register alloc]init];
//判断信息是否为空
if (([_accountField.text isEqual:@""])||( [_secretField.text isEqual:@""]) ) {
[self promptMessage:_label and:@"个人信息不能为空!"];
}
//判断用户名长度是否超限制
else if ((_accountField.text.length>12)||(_accountField.text.length<6))
{
[self promptMessage:_label and:@"请重新输入用户名"];
}
else if ([self judgeWithText:_accountField.text and:addData]!=0)
{
[self promptMessage:_label and:@"此账号已存在"];
}
else
{
//将数据添加进数据库
[addData addNewPeople:_accountField.text andSecret:_secretField.text];
//注册成功的时候给一个提示框,告诉用户注册成功
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"提示框" message:@"注册成功" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];
//注册成功自动跳转到登录界面
[self dismissViewControllerAnimated:NO completion:nil];
}
// [self dismissViewControllerAnimated:NO completion:nil];
}
-(void)back{
[self dismissViewControllerAnimated:NO completion:nil];
}
#import <UIKit/UIKit.h>
#import "ThreeViewController.h"
@interface FourViewController : UIViewController
@property(nonatomic,strong)UILabel *publishLabel;
@property(nonatomic,strong)UILabel *headingLabel;
@property(nonatomic,strong)UILabel *summarizeLabel;
@property(nonatomic,strong)UILabel *mainbodyLabel;
@property(nonatomic,strong)UITextField *headingField;
@property(nonatomic,strong)UITextField *summarizeField;
@property(nonatomic,strong)UITextView *mainbodyText;
@property(nonatomic,strong)UIButton *publishButton;
@property(nonatomic,strong)NSString *content;
@property(nonatomic,strong)ThreeViewController *threeView;
@property(nonatomic,strong)UIImageView *dogImage;
@property(nonatomic,strong)UIButton *backButton;
@end
#import <UIKit/UIKit.h>
#import "ThreeViewController.h"
@interface FourViewController : UIViewController
@property(nonatomic,strong)UILabel *publishLabel;
@property(nonatomic,strong)UILabel *headingLabel;
@property(nonatomic,strong)UILabel *summarizeLabel;
@property(nonatomic,strong)UILabel *mainbodyLabel;
@property(nonatomic,strong)UITextField *headingField;
@property(nonatomic,strong)UITextField *summarizeField;
@property(nonatomic,strong)UITextView *mainbodyText;
@property(nonatomic,strong)UIButton *publishButton;
@property(nonatomic,strong)NSString *content;
@property(nonatomic,strong)ThreeViewController *threeView;
@property(nonatomic,strong)UIImageView *dogImage;
@property(nonatomic,strong)UIButton *backButton;
@end
#import "FourViewController.h"
#import "ViewController.h"
#import "Register.h"
@interface FourViewController ()
@end
@implementation FourViewController
- (void)viewDidLoad {
[super viewDidLoad];
_threeView = [[ThreeViewController alloc]init];
_publishLabel = [[UILabel alloc]initWithFrame:CGRectMake(149, 44, 77, 21)];
_headingLabel = [[UILabel alloc]initWithFrame:CGRectMake(37, 98, 34, 21)];
_summarizeLabel = [[UILabel alloc]initWithFrame:CGRectMake(37, 160, 34, 21)];
_mainbodyLabel = [[UILabel alloc]initWithFrame:CGRectMake(33, 248, 34, 21)];
_mainbodyText = [[UITextView alloc]initWithFrame:CGRectMake(28, 300, 331, 260)];
_headingField = [[UITextField alloc]initWithFrame:CGRectMake(99, 94, 139, 30)];
_summarizeField = [[UITextField alloc]initWithFrame:CGRectMake(99, 157, 236, 30)];
_publishButton = [[UIButton alloc]initWithFrame:CGRectMake(284, 580, 43, 30)];
_backButton = [[UIButton alloc]initWithFrame:CGRectMake(70, 580, 43, 30)];
_publishLabel.text = @"发表博文";
_headingLabel.text = @"标题";
_summarizeLabel.text = @"摘要";
_mainbodyLabel.text = @"正文";
_headingField.layer.borderWidth = 1;
_headingField.layer.borderColor = [UIColor blackColor].CGColor;
_headingField.layer.cornerRadius = 9;
_summarizeField.layer.borderWidth = 1;
_summarizeField.layer.borderColor = [UIColor blackColor].CGColor;
_summarizeField.layer.cornerRadius = 9;
_mainbodyText.layer.borderWidth = 1;
_mainbodyText.layer.borderColor = [UIColor blackColor].CGColor;
_mainbodyText.layer.cornerRadius = 9;
_mainbodyText.backgroundColor =[[UIColor alloc]initWithRed:0.4 green:0.8 blue:0.976 alpha:1];
[_publishButton setTitle:@"发表" forState:UIControlStateNormal];
[_publishButton setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
_publishButton.backgroundColor = [UIColor grayColor];
_publishButton.layer.borderWidth = 2;
_publishButton.layer.cornerRadius = 5;
[_publishButton addTarget:self action:@selector(dianji) forControlEvents:UIControlEventTouchUpInside];
[_backButton setTitle:@"返回" forState:UIControlStateNormal];
[_backButton setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
_backButton.backgroundColor = [UIColor grayColor];
_backButton.layer.borderWidth = 2;
_backButton.layer.cornerRadius = 5;
[_backButton addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
_dogImage = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 375, 310)];
_dogImage.image = [UIImage imageNamed:@"a"];
[self.view addSubview:_dogImage];
[self.view addSubview:_backButton];
[self.view addSubview:_publishLabel];
[self.view addSubview:_headingLabel];
[self.view addSubview:_summarizeLabel];
[self.view addSubview:_mainbodyLabel];
[self.view addSubview:_mainbodyText];
[self.view addSubview:_headingField];
[self.view addSubview:_summarizeField];
[self.view addSubview:_publishButton];
}
-(void)dianji{
// NSLog(@"fabiao");
// ViewController *One = [[ViewController alloc]init];
// NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
// [userDefaults setValue:_headingField.text forKey:@"标题"];
// [userDefaults setObject:_summarizeField.text forKey:@"摘要"];
// [userDefaults setValue:_mainbodyText.text forKey:@"正文"];
// [userDefaults synchronize];
Register *reg = [[Register alloc]init];
[reg addContent:_headingField.text andZhai:_summarizeField.text andContent:_mainbodyText.text];
// NSArray *arr= [reg showContent];
// NSLog(@"%@",arr);
// [self presentViewController:One animated:YES completion:nil];
// [self.navigationController pushViewController:One animated:NO];
[self dismissViewControllerAnimated:NO completion:nil];
}
-(void)back{
[self dismissViewControllerAnimated:NO completion:nil];
}
#import <UIKit/UIKit.h>
#import "FourViewController.h"
#import "Register.h"
@interface FiveViewController : UIViewController
@property(nonatomic,strong)UILabel *headLabel;
@property(nonatomic,strong)UILabel *label;
@property(nonatomic,strong)UILabel *label1;
@property(nonatomic,strong)UILabel *label2;
@property(nonatomic,strong)UILabel *label3;
@property(nonatomic,strong)UILabel *label4;
@property(nonatomic,strong)UILabel *label5;
@property(nonatomic,strong)UIButton *button;
@property(nonatomic,strong)FourViewController *fourView;
@end
#import "FiveViewController.h"
#import "Register.h"
@interface FiveViewController ()
@end
@implementation FiveViewController
- (void)viewDidLoad {
[super viewDidLoad];
_headLabel = [[UILabel alloc]initWithFrame:CGRectMake(149, 44, 77, 21)];
_label = [[UILabel alloc]initWithFrame:CGRectMake(37, 98, 34, 21)];
_label1 = [[UILabel alloc]initWithFrame:CGRectMake(37, 160, 34, 21)];
_label2 = [[UILabel alloc]initWithFrame:CGRectMake(33, 248, 34, 21)];
_label3 = [[UILabel alloc]initWithFrame:CGRectMake(99, 94, 139, 30)];
_label4 = [[UILabel alloc]initWithFrame:CGRectMake(99, 157, 236, 30)];
_label5 = [[UILabel alloc]initWithFrame:CGRectMake(28, 300, 331, 260)];
_button = [[UIButton alloc]initWithFrame:CGRectMake(5, 50, 40, 21)];
_label5.numberOfLines = 15;
_headLabel.text = @"博文内容";
_label.text = @"标题";
_label1.text = @"摘要";
_label2.text = @"正文";
_label3.layer.borderWidth = 1;
_label3.layer.borderColor = [UIColor blackColor].CGColor;
_label3.layer.cornerRadius = 9;
_label4.layer.borderWidth = 1;
_label4.layer.borderColor = [UIColor blackColor].CGColor;
_label4.layer.cornerRadius = 9;
_label5.layer.borderWidth = 1;
_label5.layer.borderColor = [UIColor blackColor].CGColor;
_label5.layer.cornerRadius = 9;
_button.backgroundColor = [UIColor grayColor];
_button.layer.borderWidth = 2;
_button.layer.cornerRadius = 5;
[_button setTitle:@"返回" forState:UIControlStateNormal];
[_button setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
[_button addTarget:self action:@selector(dianji) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:_button];
[self.view addSubview:_headLabel];
[self.view addSubview:_label];
[self.view addSubview:_label1];
[self.view addSubview:_label2];
[self.view addSubview:_label3];
[self.view addSubview:_label4];
[self.view addSubview:_label5];
// NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
// _label3.text = [userDefaults valueForKey:@"标题"];
// _label4.text = [userDefaults valueForKey:@"摘要"];
// _label5.text = [userDefaults valueForKey:@"正文"];
NSMutableArray *array=[[NSMutableArray alloc]init];
Register *data = [[Register alloc]init];
array=[data showContent];
NSInteger a=(long)[array count];
NSLog(@"%li",a);
_label3.text = array[a-1][@"title"];
_label4.text = array[a-1][@"zhai"];
_label5.text = array[a-1][@"content"];
NSUserDefaults *userDefault = [[NSUserDefaults alloc]init];
_label3.text = [userDefault valueForKey:@"title"];
_label4.text = [userDefault valueForKey:@"zhai"];
_label5.text = [userDefault valueForKey:@"content"];
}
-(void)dianji{
[self dismissViewControllerAnimated:NO completion:nil];
}
#import <UIKit/UIKit.h>
#import "FiveViewController.h"
@interface SixViewController : UIViewController<UITableViewDataSource,UITableViewDelegate>
@property(nonatomic,strong)NSArray *array;
@property(nonatomic,strong)UILabel *label;
@property(nonatomic,strong)NSString *nowTime;
@property(nonatomic,strong)UIButton *buttonBack;
@property(nonatomic,strong)FiveViewController *fiveView;
@end
#import "SixViewController.h"
#import "Register.h"
@interface SixViewController ()
@property(nonatomic,strong)NSMutableArray *arrayContect;
@end
@implementation SixViewController
- (void)viewDidLoad {
[super viewDidLoad];
Register *regist=[[Register alloc]init];
_arrayContect=[[NSMutableArray alloc]initWithCapacity:10];
_arrayContect=[regist showContent];
UITableView *tableview = [[UITableView alloc]initWithFrame:[[UIScreen mainScreen]bounds] style:UITableViewStyleGrouped];
tableview.delegate = self;
tableview.dataSource = self;
NSDate *date = [[NSDate alloc]init];
NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
[formatter setDateFormat:@"yyyy-MM-dd HH-mm-ss"];
_nowTime = [formatter stringFromDate:date];
[self.view addSubview:tableview];
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return [_arrayContect count];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
if (cell == nil) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"];
}
NSLog(@"-----%@",_arrayContect);
cell.textLabel.text =_arrayContect[indexPath.row][@"title"];
cell.detailTextLabel.text = _nowTime;
return cell;
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
if (section == 0) {
UIView *view=[[UIView alloc]init];
view.frame=CGRectMake(0, 0, tableView.frame.size.width, 180);
UIImageView *imageView=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"6"]];
imageView.frame=CGRectMake(0, 0, tableView.frame.size.width, 120);
UILabel *label=[[UILabel alloc]init];
label.text=@"标题";
label.frame=CGRectMake(15, 135, 50, 10);
// _buttonBack = [[UIButton alloc]initWithFrame:CGRectMake(300, 125, 50, 20)];
// [_buttonBack setTitle:@"返回" forState:UIControlStateNormal];
// [_buttonBack setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
// _buttonBack.backgroundColor = [UIColor grayColor];
// _buttonBack.layer.borderWidth = 2;
// _buttonBack.layer.cornerRadius = 5;
// [_buttonBack addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
[view addSubview:imageView];
[view addSubview:label];
// [view addSubview:_buttonBack];
return view;
}
_label.frame=CGRectMake(15, 5, 10, 10);
return _label;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
if (section==0) {
return 150;
}
return 20;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
NSInteger a=(long)[indexPath row];
// NSLog(@"yyyyyy%ld",(long)[indexPath row]);
NSMutableArray *array=[[NSMutableArray alloc]init];
Register *data = [[Register alloc]init];
array=[data showContent];
NSLog(@"%@",array[a]);
NSUserDefaults *userDefault = [[NSUserDefaults alloc]init];
[userDefault setValue:_arrayContect[indexPath.row][@"title"] forKey:@"title"];
[userDefault setValue:_arrayContect[indexPath.row][@"zhai"] forKey:@"zhai"];
[userDefault setValue:_arrayContect[indexPath.row][@"content"] forKey:@"content"];
[userDefault synchronize];
_fiveView = [[FiveViewController alloc]init];
[self presentViewController:_fiveView animated:YES completion:nil];
}
//-(void)back{
// [self dismissViewControllerAnimated:NO completion:nil];
//}
#import <UIKit/UIKit.h>
#import "TextViewController.h"
@interface SevenViewController : UIViewController
@property(nonatomic,strong)UIButton *buttonText1;
@property(nonatomic,strong)UILabel *labelText1;
@property(nonatomic,strong)UIImageView *image;
@property(nonatomic,strong)UIButton *backButton;
@property(nonatomic,strong)TextViewController *textView1;
@property(nonatomic,strong)UIImageView *imageDog;
@end
import "SevenViewController.h"
@interface SevenViewController ()
@end
@implementation SevenViewController
- (void)viewDidLoad {
[super viewDidLoad];
_image = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 375, 200)];
_image.image = [UIImage imageNamed:@"a"];
_labelText1 = [[UILabel alloc]initWithFrame:CGRectMake(90, 220, 209, 30)];
_buttonText1 = [[UIButton alloc]initWithFrame:CGRectMake(105, 220, 180, 30)];
_backButton = [[UIButton alloc]initWithFrame:CGRectMake(290, 600, 43, 43)];
_imageDog = [[UIImageView alloc]initWithFrame:CGRectMake(0, 270, 375, 300)];
_imageDog.image = [UIImage imageNamed:@"0"];
[_backButton setTitle:@"返回" forState:UIControlStateNormal];
[_backButton setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
_backButton.backgroundColor = [UIColor grayColor];
_backButton.layer.borderWidth = 2;
_backButton.layer.cornerRadius = 5;
[_backButton addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
[_buttonText1 setTitle:@"拉布拉多" forState:UIControlStateNormal];
[_buttonText1 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
_labelText1.layer.borderWidth = 1;
_labelText1.layer.borderColor = [UIColor blackColor].CGColor;
_labelText1.layer.cornerRadius = 9;
[_buttonText1 addTarget:self action:@selector(text1) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:_backButton];
[self.view addSubview:_buttonText1];
[self.view addSubview:_image];
[self.view addSubview:_labelText1];
[self.view addSubview:_imageDog];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(void)back{
[self dismissViewControllerAnimated:NO completion:nil];
}
-(void)text1{
_textView1 = [[TextViewController alloc]init];
[self presentViewController:_textView1 animated:YES completion:nil];
}
#import <UIKit/UIKit.h>
@interface TextViewController : UIViewController
@property(nonatomic,strong)UILabel *labelText;
@property(nonatomic,strong)UIImageView *image;
@property(nonatomic,strong)UIButton *backButton;
@property(nonatomic,strong)UILabel *headLabel;
@property(nonatomic,strong)NSString *dogInformation;
@end
#import "TextViewController.h"
@interface TextViewController ()
@end
@implementation TextViewController
- (void)viewDidLoad {
[super viewDidLoad];
_labelText = [[UILabel alloc]initWithFrame:CGRectMake(24, 300, 331, 260)];
_labelText.numberOfLines = 15;
_image = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 375, 200)];
_backButton = [[UIButton alloc]initWithFrame:CGRectMake(290, 600, 43, 43)];
_headLabel = [[UILabel alloc]initWithFrame:CGRectMake(90, 220, 209, 30)];
_headLabel.text = @"拉布拉多";
_headLabel.textAlignment = NSTextAlignmentCenter;
_headLabel.layer.borderWidth = 1;
_headLabel.layer.borderColor = [UIColor blackColor].CGColor;
_headLabel.layer.cornerRadius = 9;
[_backButton setTitle:@"返回" forState:UIControlStateNormal];
[_backButton setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
_backButton.backgroundColor = [UIColor grayColor];
_backButton.layer.borderWidth = 2;
_backButton.layer.cornerRadius = 5;
[_backButton addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
_image.image = [UIImage imageNamed:@"a"];
_labelText.layer.borderWidth = 1;
_labelText.layer.borderColor = [UIColor blackColor].CGColor;
_labelText.layer.cornerRadius = 9;
_dogInformation= @"拉布拉多猎犬是一种中大型犬类,个性温和、活泼,智商极高,也对人很友善,是非常适合被选作导盲犬或其他工作犬的狗品种,跟哈士奇(西伯利亚雪撬犬)和金毛猎犬并列三大无攻击性犬类,拉布拉多智商位列世界犬类第七。";
_labelText.text = _dogInformation;
[self.view addSubview:_headLabel];
[self.view addSubview:_backButton];
[self.view addSubview:_image];
[self.view addSubview:_labelText];
}
-(void)back{
[self dismissViewControllerAnimated:NO completion:nil];
}