作業(yè)

新建niuTableViewCell ?繼承UITableViewCell

新建zhexian ?繼承uiview

新建tabbarViewController ? ?繼承UITabBarController

新建oneViewController ? 繼承UIViewController

新建twoViewController ? ? ?threeViewController ? ?fourViewController ? ?fiveViewController ?


在AppDelegate.M 中

導(dǎo)入#import "tabbarViewController.h"

?self.window.rootViewController = [tabbarViewController new];

在niuTableViewCell.h中

@property(nonatomic,strong)UIImageView *imageV;

@property(nonatomic,strong)UILabel *textL;

@property(nonatomic,strong)UILabel *detaL;

@property(nonatomic,strong)UILabel *dateL;



niuTableViewCell.m中

-(UIImageView *)imageV

{

? ? if(!_imageV) {

? ? ? ? _imageV= [[UIImageViewalloc]init];

? ? ? ? _imageV.frame=CGRectMake(FIT_X(20),FIT_X(5),FIT_X(90),FIT_X(70));

? ? }

? ? return _imageV;

}

-(UILabel*)textL

{

? ? if(!_textL) {

? ? ? ? _textL= [[UILabelalloc]init];

? ? ? ? _textL.frame=CGRectMake(self.imageV.frame.origin.x+self.imageV.frame.size.width+FIT_X(10),FIT_X(20),SCR_W-FIT_X(140),FIT_X(40));

? ? ? ? _textL.font= [UIFontsystemFontOfSize:14];

? ? ? ? _textL.numberOfLines = 0;

? ? }

? ? return _textL;

}

-(UILabel*)detaL

{

? ? if(!_detaL) {

? ? ? ? _detaL= [[UILabelalloc]init];

? ? ? ? _detaL.frame = CGRectMake(self.imageV.frame.origin.x + self.imageV.frame.size.width + FIT_X(10),self.textL.frame.origin.y + self.textL.frame.size.height, FIT_X(80), FIT_X(12));

//? ? ? ? _detaL.frame = CGRectMake(10,10,10,10);


? ? ? ? _detaL.font= [UIFontsystemFontOfSize:12];

? ? ? ? _detaL.textColor = [UIColor yellowColor];

? ? }

? ? return _detaL;

}

-(UILabel*)dateL

{

? ? if(!_dateL) {

? ? ? ? _dateL= [[UILabelalloc]init];

? ? ? ? _dateL.frame=CGRectMake(self.detaL.frame.origin.x+self.detaL.frame.size.width+FIT_X(10),FIT_X(60),FIT_X(50),FIT_X(10));

? ? ? ? _dateL.font= [UIFontsystemFontOfSize:12];

//? ? ? ? _dateL.frame = CGRectMake(10, 10, 10, 10);



? ? }

? ? return _dateL;

}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString*)reuseIdentifier

{

? ? self= [superinitWithStyle:stylereuseIdentifier:reuseIdentifier];

? ? if(self) {

? ? ? ? [selfaddSubview:self.imageV];

? ? ? ? [selfaddSubview:self.textL];

? ? ? ? [selfaddSubview:self.detaL];

? ? ? ? [selfaddSubview:self.dateL];

? ? }

? ? return self;

}

- (void)awakeFromNib {

? ? [super awakeFromNib];

? ? // Initialization code

}

在tabbarViewController.m中

導(dǎo)入#import "oneViewController.h"

#import "twoViewController.h"

#import "threeViewController.h"

#import "fourViewController.h"

#import "fiveViewController.h"

并且

- (void)viewDidLoad {

? ? [super viewDidLoad];

? ? oneViewController *one = [oneViewController new];

? ? UINavigationController *oneNav = [[UINavigationController alloc]initWithRootViewController:one];

? ? oneNav.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"首頁(yè)" image:[UIImage imageNamed:@"笑臉1@2x.png"] selectedImage:[UIImage imageNamed:@"笑臉1@2x.png"]];


? ? twoViewController *two = [twoViewController new];

? ? UINavigationController *twoNav = [[UINavigationController alloc]initWithRootViewController:two];

? ? twoNav.tabBarItem= [[UITabBarItemalloc]initWithTitle:@"養(yǎng)牛寶"image:[UIImageimageNamed:@"笑臉1@2x.png"]selectedImage:[UIImageimageNamed:@"笑臉1@2x.png"]];


? ? threeViewController *three = [threeViewController new];

? ? UINavigationController *threeNav = [[UINavigationController alloc]initWithRootViewController:three];

? ? threeNav.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"" image:[UIImage imageNamed:@"笑臉1@2xt.png"] selectedImage:[UIImage imageNamed:@"笑臉1@2xt.png"]];


? ? fourViewController *four = [fourViewController new];

? ? UINavigationController *fourNav = [[UINavigationController alloc]initWithRootViewController:four];

? ? fourNav.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"繪牛咨詢(xún)" image:[UIImage imageNamed:@"笑臉1@2x.png"] selectedImage:[UIImage imageNamed:@"笑臉1@2x.png"]];

? ? fiveViewController *five = [fiveViewController new];

? ? UINavigationController *fiveNav = [[UINavigationController alloc]initWithRootViewController:five];

? ? fiveNav.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"我的" image:[UIImage imageNamed:@"笑臉1@2x.png"] selectedImage:[UIImage imageNamed:@"笑臉1@2x.png"]];


? ? self.viewControllers=@[oneNav,twoNav,threeNav,fourNav,fiveNav];


? ? // Do any additional setup after loading the view.

}


在oneViewController.m中


導(dǎo)入#import "niuTableViewCell.h"

#import "zhexian.h"

并且 繼承

uitableviewdelegate ? uitableviewdatasouse ?uisearchbardelegate

{

? ? NSArray*arr1;

}

@end

@implementationoneViewController

- (void)viewDidLoad {

? ? [super viewDidLoad];

? ? self.view.backgroundColor = [UIColor whiteColor];


? ? UISearchBar*searchbar = [[UISearchBaralloc]initWithFrame:CGRectMake(FIT_X(10),FIT_X(20),SCR_W-FIT_X(30),FIT_X(20))];

? ? searchbar.delegate=self;


? ? [searchbarsetTintColor:[UIColor cyanColor]];


? ? [searchbarsetPlaceholder:@"搜索"];


//? ? [self.navigationController.]

? ? UIBarButtonItem* searchButton = [[UIBarButtonItemalloc]initWithCustomView:searchbar];


//? ? UIView *titleView = [[UIView alloc]initWithFrame:CGRectMake(15,80,SCR_W-100,30)];

//? ? titleView.backgroundColor = [UIColor cyanColor];

//? ? [self.view addSubview:titleView];


//? ? self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(fenshou)];

? ? ?self.navigationItem.rightBarButtonItem = searchButton;


? ? self.navigationController.navigationBar.barTintColor = [UIColor yellowColor];

//? ? arr1 = @[@"image4.jpg",@"image4.jpg",@"image4.jpg",@"image4.jpg"];

? ? UITableView *table = [[UITableView alloc]initWithFrame:CGRectMake(0, FIT_X(400), SCR_W, FIT_X(250)) style:UITableViewStyleGrouped];

? ? table.delegate=self;

? ? table.dataSource=self;

? ? table.rowHeight=90;

? ? [self.viewaddSubview:table];


? ? zhexian*zhexianView = [[zhexianalloc]initWithFrame:CGRectMake(0,40,SCR_W,FIT_X(390))];

? ? [self.viewaddSubview:zhexianView];

}

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

{

? ? return 10;

}

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

{

? ? staticNSString*reuse =@"cell";

? ? niuTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuse];

? ? if(cell ==nil) {

? ? ? ? cell = [[niuTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuse];


? ? }

? ? cell.imageV.image= [UIImageimageNamed:@"image4.jpg"];

? ? cell.textL.text = @"當(dāng)今最好的十大肉牛品種,我們?cè)撊绾芜x擇合適的肉牛品種";

? ? cell.detaL.text=@"中國(guó)養(yǎng)殖業(yè)聯(lián)盟";

? ? cell.dateL.text=@"/6-19";

? ? returncell;

}

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容