日語詞典介面

來源:互聯網
上載者:User

標籤:style   color   os   io   for   2014   ar   cti   

//

//  ViewController.m

//  JapaneseDictionary

//

//  Created by apple on 14-8-7.

//  Copyright (c) 2014年 蘋果IOS軟體開發人員. All rights reserved.

//

 

#import "ViewController.h"

#import "secondViewController.h"

@interface ViewController ()<UITableViewDataSource,UITableViewDelegate>

{

    UITableView *tableview;

    UITextField *textfiled;

}

@end

 

@implementation ViewController

 

- (void)createbuttons

{   //1.設定搜尋按鈕

    UIButton *searchbtn = [[UIButton alloc]initWithFrame:CGRectMake(270, 25, 40, 25)];

    [searchbtn setTitle:@"翻譯"forState:UIControlStateNormal];

    

    [searchbtn addTarget:self action:@selector(didsearch:) forControlEvents:UIControlEventTouchUpInside];

    [self.view addSubview:searchbtn];

    

    //2.設定清除按鈕

    UIButton *clearbtn = [UIButton buttonWithType:UIButtonTypeCustom];

    [clearbtn setImage:[UIImage imageNamed:@"clearBtn"] forState:UIControlStateNormal];

    clearbtn.frame = CGRectMake(130, 440, 60, 30);

    [clearbtn addTarget:self action:@selector(didclear) forControlEvents:UIControlEventTouchUpInside];

    [self.view addSubview:clearbtn];

    

    }

- (void)createTextfiled{

    textfiled = [[UITextField alloc] initWithFrame:CGRectMake(80, 25, 180, 25)];

    

    [textfiled setBorderStyle:UITextBorderStyleRoundedRect];

    [self.view addSubview:textfiled];

    

}

 

- (void)createLabel{

    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 28, 80, 20)];

    label.text = [NSString stringWithFormat:@"日語詞典"];

    label.textColor =[UIColor whiteColor];

    label.textAlignment = NSTextAlignmentCenter;

    [self.view addSubview:label];

}

 

- (void)createBackgroundimage

{

   

    UIImageView *titleImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 17, 320, 49)];

    titleImageView.image = [UIImage imageNamed:@"titleView"];

    [self.view addSubview:titleImageView];

    

    UIImageView *footerImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height - 49, 320, 49)];

    footerImageView.image = [UIImage imageNamed:@"bottomBg"];

    [self.view addSubview:footerImageView];

    

    

}

- (void)didsearch:(UIButton *)sender

{

    tableview = [[UITableView alloc] initWithFrame:CGRectMake(0, 70, 300, self.view.frame.size.height-118) style:UITableViewStylePlain];

    tableview.dataSource = self;

    tableview.delegate = self;

    tableview.rowHeight = 40;

    [self.view addSubview:tableview];

 

}

 

- (void)didclear

{

    //移除當前案頭

    [tableview removeFromSuperview];

    textfiled.text [email protected]"";

}

 

 

- (void)viewDidLoad {

    [super viewDidLoad];

        [self createBackgroundimage];

    [self createTextfiled];

    [self createLabel];

    [self createbuttons];

       // Do any additional setup after loading the view, typically from a nib.

}

 

 

- (void)didReceiveMemoryWarning {

    [super didReceiveMemoryWarning];

    

}

 

#pragma mark - UITableViewDataSource

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

{

    //返回表格的行數

    return 10;

}

 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{

    //擷取已有的Cell

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];

    if (cell == nil) {

        //建立一個Cell

        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];

    }

    

    //在Cell上顯示文字

    cell.textLabel.text = [NSString stringWithFormat:@"%d", indexPath.row];

    return cell;

}

 

 

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;

{

    

    secondViewController *secondCtrl = [[secondViewController alloc] init];

    //彈出查詢結果介面

    [self presentViewController:secondCtrl animated:YES completion:nil];

}

 

 

 

@end

 

 

 

 

//

//  secondViewController.m

//  JapaneseDictionary

//

//  Created by apple on 14-8-7.

//  Copyright (c) 2014年 蘋果IOS軟體開發人員. All rights reserved.

//

 

#import "secondViewController.h"

 

 

@interface secondViewController ()

@end

 

@implementation secondViewController

 

 

- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil

{

    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];

    if (self) {

        // Custom initialization

    }

    return self;

}

 

- (void)AddButtons

{

    //1.設定返回按鈕

    UIButton * backbtn = [UIButton buttonWithType:UIButtonTypeCustom];

    [backbtn setImage:[UIImage imageNamed:@"backBtn"] forState:UIControlStateNormal];

    backbtn.frame = CGRectMake(20, 30, 50, 30);

    [backbtn addTarget:self action:@selector(didback) forControlEvents:UIControlEventTouchUpInside];

    [self.view addSubview:backbtn];

    

    //2.設定發音按鈕

    UIButton * pronouncebtn = [UIButton buttonWithType:UIButtonTypeCustom];

    [pronouncebtn setImage:[UIImage imageNamed:@"pronounceBtn_01"] forState:UIControlStateNormal];

    //按下去是高亮狀態

    [pronouncebtn setImage:[UIImage imageNamed:@"pronounceBtn_02"] forState:UIControlStateHighlighted];

    pronouncebtn.frame = CGRectMake(255, 30, 50, 30);

    [pronouncebtn addTarget:self action:@selector(didpronounce) forControlEvents:UIControlEventTouchUpInside];

    [self.view addSubview:pronouncebtn];

    

    

}

 

- (void)AddLabel{

    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(20, 35, 280, 460)];

    label.text = [NSString stringWithFormat:@"資訊"];

    label.textColor =[UIColor blackColor];

    label.textAlignment = NSTextAlignmentCenter;

    [self.view addSubview:label];

}

 

- (void)viewDidLoad

{

    [super viewDidLoad];

    self.view.backgroundColor = [UIColor whiteColor];

    UIImageView *resultview = [[UIImageView alloc] initWithFrame:CGRectMake(0, 14, 320,self.view.frame.size.height - 14)];

    

    resultview.image = [UIImage imageNamed:@"tips_line"];

    [self.view addSubview:resultview];

    [self AddButtons];

    [self AddLabel];

   

   }

 

- (void)didback

{

    //使模態視圖消失

    [self dismissViewControllerAnimated:YES completion:nil];

}

 

- (void)didpronounce

{

    

}

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.