iOS-圖書管理系統(tǒng)

 // 判斷程序是否第一次打開
NSUserDefaults *TimeOfBootCount = [NSUserDefaults standardUserDefaults];
if (![TimeOfBootCount valueForKey:@"firstLaunch"])
    {
        [TimeOfBootCount setBool:YES forKey:@"firstLaunch"];
        ViewController *v1 = [[ViewController alloc]init];
    self.window.rootViewController = v1;
        NSLog(@"第一次啟動");
        
    }
    else
        
    {
        NextViewController *next1 = [[NextViewController alloc]init];
        self.window.rootViewController = next1;
        NSLog(@"不是第一次啟動");
        }
[self.window makeKeyAndVisible];
    NSLog(@"啟動成功");


屏幕快照 2017-11-23 下午1.06.01.png

#import "ViewController.h"
#import "NextViewController.h"
#import "AppDelegate.h"
@interface ViewController ()
{
    // 創(chuàng)建滾動視圖
    UIScrollView *theScroll;
    // 創(chuàng)建頁碼視圖
    UIPageControl *thePage;
    // 創(chuàng)建圖片的數(shù)組
    NSArray *theArr;
    // 創(chuàng)建整形類
    NSInteger teg;
    // 創(chuàng)建計(jì)時(shí)器
    NSTimer *theTime;
}

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // 獲取當(dāng)前屏幕的寬
    float width  = self.view.frame.size.width;
    float height = self.view.frame.size.height;
    // 初始化滾動視圖
    theScroll = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, width, height)];
    float X = 0.0;
    for (int i =0; i<4; i++)
        
    {
        
        // 創(chuàng)建圖片視圖
        
        UIImageView *theImg = [[UIImageView alloc]initWithFrame:CGRectMake(X, 0, width, height)];
        
        // 將圖片添加帶數(shù)組中
        
        theArr = @[[UIImage imageNamed:@"ww"],[UIImage imageNamed:@"Y1"],[UIImage imageNamed:@"Y2"],[UIImage imageNamed:@"Y3"]];
        
        // 將圖片與數(shù)據(jù)聯(lián)系
        
        theImg.image = theArr[i];
        
        // 將圖片添加到滾動視圖上
        
        [theScroll addSubview:theImg];
        
        // X依次遞增
        
        X += width;
        
    }
    // 設(shè)置滾動視圖內(nèi)容大小
    
    theScroll.contentSize = CGSizeMake(width *4, height);
    
    // 設(shè)置是否按頁滾動
    
    theScroll.pagingEnabled = YES;
    
    // 隱藏滾動條
    
    theScroll.showsHorizontalScrollIndicator = NO;
    
    // 設(shè)置代理
    
    theScroll.delegate = self;
    
    // 創(chuàng)建頁碼
    
    thePage = [[UIPageControl alloc]initWithFrame:CGRectMake(width / 2-50, 570, 100, 30)];
    
    // 清除頁碼的背景顏色
    
    thePage.backgroundColor = [UIColor clearColor];
    
    // 設(shè)置當(dāng)前頁碼的顏色
    
    thePage.currentPageIndicatorTintColor = [UIColor blackColor];
    
    // 設(shè)置頁碼的顏色
    
    thePage.pageIndicatorTintColor = [UIColor redColor];
    
    // 設(shè)置頁碼的個(gè)數(shù)
    thePage.numberOfPages = 4;
    
    // 設(shè)置頁碼的起始頁碼
    
    thePage.currentPage = 0;
    
    // 添加到視圖上
    
    // 先添加滾動視圖
    
    [self.view addSubview:theScroll];
    
    // 再添加頁碼視圖
    
    [self.view addSubview:thePage];
    
    // 使用整形變量接受頁碼當(dāng)前的頁碼
    
    teg = thePage.currentPage;
    
    // 創(chuàng)建定時(shí)器
    
    theTime = [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(scroll) userInfo:nil repeats:YES];

}
// 定時(shí)器的方法

- (void)scroll

{
    
    teg ++;
    
    if (teg >= theArr.count)
        
    {
        
        teg = 0;
        
    }
    
    // 設(shè)置滾動視圖的內(nèi)容偏移量
    
    [theScroll setContentOffset:CGPointMake(teg *self.view.frame.size.width, 0) animated:YES];
    
}

// 滾動視圖的代理方法
- (void)scrollViewDidScroll:(UIScrollView *)scrollView

{
    
    CGPoint point = theScroll.contentOffset;
    
    thePage.currentPage = point.x/scrollView.frame.size.width;
    
    // 創(chuàng)建按鈕
    
    UIButton *theBtn = [[UIButton alloc]init];
    
    if (thePage.currentPage == 3)
        
    {
        
        [theTime setFireDate:[NSDate distantFuture]];
        
        // 當(dāng)滾動到最后一張圖片的時(shí)候出現(xiàn)按鈕
        
        // 設(shè)置按鈕位置 z
        
        theBtn.frame = CGRectMake(230, 607, 100, 40);
        
        // 設(shè)置按鈕內(nèi)容
        
        [theBtn setTitle:@"立即體驗(yàn)" forState:UIControlStateNormal];
        
        // 設(shè)置按鈕背景顏色
        
        theBtn.backgroundColor = [UIColor redColor];
        
        // 設(shè)置按鈕響應(yīng)事件
        
        [theBtn addTarget:self action:@selector(click) forControlEvents:UIControlEventTouchUpInside];
        
        // 添加到視圖上 B
        
        [self.view addSubview:theBtn];
    }
}
// 按鈕方法
- (void)click
{
    NextViewController *next = [[NextViewController alloc]init];
    AppDelegate *app = (AppDelegate *)[UIApplication sharedApplication].delegate;
    app.window.rootViewController = next;
}


屏幕快照 2017-11-23 下午1.11.28.png
屏幕快照 2017-11-23 下午1.11.37.png
屏幕快照 2017-11-23 下午1.11.47.png
 MyViewController* my = [[MyViewController alloc]init];
    UINavigationController* myNvc = [[UINavigationController alloc]initWithRootViewController:my];
    myNvc.title = @"我";
    myNvc.tabBarItem.image = [UIImage imageNamed:@"my"];
    
    self.viewControllers = @[maiNvc,jingNvc,fuwuNvc,myNvc];

@interface MyViewController ()<UITableViewDelegate,UITableViewDataSource>
{
    //文字?jǐn)?shù)組
    NSArray* arr1,*arr2;
    //圖片數(shù)組
    NSArray* arrimg1,*arrimg2;
}
@property(nonatomic,strong)UITableView* tableview;
@end

@implementation MyViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    //設(shè)置背景顏色
    self.view.backgroundColor = [UIColor whiteColor];
    //導(dǎo)航左按鈕
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemOrganize target:self action:@selector(way1)];
    //導(dǎo)航右按鈕
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks target:self action:@selector(way2)];
    //表格初始化
    self.tableview = [[UITableView alloc]initWithFrame:CGRectMake(0, -35, self.view.frame.size.width, self.view.frame.size.height) style:UITableViewStyleGrouped];
    self.tableview.delegate = self;
    self.tableview.dataSource = self;
    [self.view addSubview:self.tableview];
    
    arr1 = [NSArray arrayWithObjects:@"卡包",@"賬單",@"會員中心",@"我的資產(chǎn)", nil];
    arr2 = [NSArray arrayWithObjects:@"我的白條",@"我的金條",@"我的保險(xiǎn)",@"我的眾籌", nil];
    arrimg1 = [NSArray arrayWithObjects:[UIImage imageNamed:@"Y1"], [UIImage imageNamed:@"Y2"], [UIImage imageNamed:@"Y3"], [UIImage imageNamed:@"ww"], nil];
    arrimg2 = [NSArray arrayWithObjects:[UIImage imageNamed:@"Y1"], [UIImage imageNamed:@"Y2"], [UIImage imageNamed:@"Y3"], [UIImage imageNamed:@"ww"], nil];
}
//設(shè)置每一分區(qū)單元格數(shù)量
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (section == 0) {
        return 2;
    }
    else if (section == 1){
        return 4;
    }
    else if (section == 2){
        return 4;
    }
    return 0;
}
//設(shè)置分區(qū)
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 3;
}
//設(shè)置分區(qū)每一單元格高度
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        if (indexPath.row == 0) {
           return 120;
        }
        else if (indexPath.row == 1){
            return 110;
        }
       
    }
    else
    {
        return 60;
    }
    return 0;
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:@" "];
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@" "];
    }
     if (indexPath.section == 0){
        if (indexPath.row == 0) {
            //設(shè)置頭像
            UIImageView* img = [[UIImageView alloc]initWithFrame:CGRectMake(20, 20, 70, 70)];
            img.image = [UIImage imageNamed:@"ww"];
            img.layer.cornerRadius = img.frame.size.width/2.0;
            img.layer.masksToBounds = YES;
            [cell addSubview:img];
            //右側(cè)箭頭
            cell.accessoryType = YES;
            //設(shè)置登錄文字
            UILabel* lab1 = [[UILabel alloc]initWithFrame:CGRectMake(100, 27, 100, 40)];
            lab1.text = @"立即登錄";
            lab1.font = [UIFont systemFontOfSize:18];
            [cell addSubview:lab1];
            
            //設(shè)置登錄下方文字
            UILabel* lab2 = [[UILabel alloc]initWithFrame:CGRectMake(100, 53, 200, 40)];
            lab2.text = @"首次登錄,領(lǐng)666元大禮包";
            lab2.textColor = [UIColor orangeColor];
            lab2.font = [UIFont systemFontOfSize:12];
            [cell addSubview:lab2];
        }
        else if (indexPath.row == 1){
 //按鈕1----------------------------------------------------------
            UIButton* button1 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            button1.frame = CGRectMake(20, 10, 70, 70);
            button1.clipsToBounds=YES;
            button1.layer.cornerRadius=35;
            button1.backgroundColor = [UIColor grayColor];
            [button1 addTarget:self action:@selector(btn1) forControlEvents:UIControlEventTouchUpInside];
            [cell addSubview:button1];
            
            UILabel* lab1 = [[UILabel alloc]initWithFrame:CGRectMake(35, 80, 100, 40)];
            lab1.text = @"簽到";
            lab1.textColor = [UIColor grayColor];
            [cell addSubview:lab1];
//按鈕2----------------------------------------------------------
            UIButton* button2 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            button2.frame = CGRectMake(115, 10, 70, 70);
            button2.clipsToBounds=YES;
            button2.layer.cornerRadius=35;
            button2.backgroundColor = [UIColor grayColor];
            [button2 addTarget:self action:@selector(btn2) forControlEvents:UIControlEventTouchUpInside];
            [cell addSubview:button2];
            
            UILabel* lab2 = [[UILabel alloc]initWithFrame:CGRectMake(115, 80, 100, 40)];
            lab2.text = @"早起打卡";
            lab2.textColor = [UIColor grayColor];
            [cell addSubview:lab2];
   
 //按鈕3----------------------------------------------------------
            UIButton* button3 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            button3.frame = CGRectMake(210, 10, 70, 70);
            button3.clipsToBounds=YES;
            button3.layer.cornerRadius=35;
            button3.backgroundColor = [UIColor grayColor];
            [button3 addTarget:self action:@selector(btn3) forControlEvents:UIControlEventTouchUpInside];
            [cell addSubview:button3];
            
            UILabel* lab3 = [[UILabel alloc]initWithFrame:CGRectMake(225, 80, 100, 40)];
            lab3.text = @"日歷";
            lab3.textColor = [UIColor grayColor];
            [cell addSubview:lab3];
            
 //按鈕4----------------------------------------------------------
            UIButton* button4 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
            button4.frame = CGRectMake(310, 10, 70, 70);
            button4.clipsToBounds=YES;
            button4.layer.cornerRadius=35;
            button4.backgroundColor = [UIColor grayColor];
            [button4 addTarget:self action:@selector(btn4) forControlEvents:UIControlEventTouchUpInside];
            [cell addSubview:button4];
            
            UILabel* lab4 = [[UILabel alloc]initWithFrame:CGRectMake(325, 80, 100, 40)];
            lab4.text = @"任務(wù)";
            lab4.textColor = [UIColor grayColor];
            [cell addSubview:lab4];
        }
    }
     if (indexPath.section == 1){
         cell.imageView.image = arrimg1[indexPath.row];
         cell.textLabel.text = arr1[indexPath.row];
         
     }
    if (indexPath.section == 2){
        cell.imageView.image = arrimg2[indexPath.row];
        cell.textLabel.text = arr2[indexPath.row];
    }
    return cell;
}
//按鈕式
-(void)btn1{
    UIAlertView* btn11 = [[UIAlertView alloc]initWithTitle:@"提示" message:@"簽到" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"確定", nil];
    [btn11 show];
}
-(void)btn2{
    UIAlertView* btn11 = [[UIAlertView alloc]initWithTitle:@"提示" message:@"早起打卡" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"確定", nil];
    [btn11 show];
}
-(void)btn3{
    UIAlertView* btn11 = [[UIAlertView alloc]initWithTitle:@"提示" message:@"日歷" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"確定", nil];
    [btn11 show];
}
-(void)btn4{
    UIAlertView* btn11 = [[UIAlertView alloc]initWithTitle:@"提示" message:@"任務(wù)" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"確定", nil];
    [btn11 show];
}
-(void)way1{
    UIAlertView* alter1 = [[UIAlertView alloc]initWithTitle:@"提示" message:@"我" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"確定", nil];
    [alter1 show];
}
-(void)way2{
    UIAlertView* alter2 = [[UIAlertView alloc]initWithTitle:@"提示" message:@"我" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"確定", nil];
    [alter2 show];
}











最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末桶蛔,一起剝皮案震驚了整個(gè)濱河市近刘,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌捣作,老刑警劉巖,帶你破解...
    沈念sama閱讀 216,496評論 6 501
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異少办,居然都是意外死亡,警方通過查閱死者的電腦和手機(jī)诵原,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,407評論 3 392
  • 文/潘曉璐 我一進(jìn)店門英妓,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人绍赛,你說我怎么就攤上這事蔓纠。” “怎么了吗蚌?”我有些...
    開封第一講書人閱讀 162,632評論 0 353
  • 文/不壞的土叔 我叫張陵腿倚,是天一觀的道長。 經(jīng)常有香客問我蚯妇,道長敷燎,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,180評論 1 292
  • 正文 為了忘掉前任侮措,我火速辦了婚禮懈叹,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘分扎。我一直安慰自己澄成,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,198評論 6 388
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著墨状,像睡著了一般卫漫。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上肾砂,一...
    開封第一講書人閱讀 51,165評論 1 299
  • 那天列赎,我揣著相機(jī)與錄音,去河邊找鬼镐确。 笑死包吝,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的源葫。 我是一名探鬼主播诗越,決...
    沈念sama閱讀 40,052評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼息堂!你這毒婦竟也來了嚷狞?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 38,910評論 0 274
  • 序言:老撾萬榮一對情侶失蹤荣堰,失蹤者是張志新(化名)和其女友劉穎床未,沒想到半個(gè)月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體振坚,經(jīng)...
    沈念sama閱讀 45,324評論 1 310
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡薇搁,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,542評論 2 332
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了渡八。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片只酥。...
    茶點(diǎn)故事閱讀 39,711評論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖呀狼,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情损离,我是刑警寧澤哥艇,帶...
    沈念sama閱讀 35,424評論 5 343
  • 正文 年R本政府宣布,位于F島的核電站僻澎,受9級特大地震影響貌踏,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜窟勃,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,017評論 3 326
  • 文/蒙蒙 一祖乳、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧秉氧,春花似錦眷昆、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,668評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽作媚。三九已至,卻和暖如春帅刊,著一層夾襖步出監(jiān)牢的瞬間纸泡,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 32,823評論 1 269
  • 我被黑心中介騙來泰國打工赖瞒, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留女揭,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 47,722評論 2 368
  • 正文 我出身青樓栏饮,卻偏偏與公主長得像吧兔,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個(gè)殘疾皇子抡爹,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,611評論 2 353

推薦閱讀更多精彩內(nèi)容