iOS 模仿饿了吗首页

AppDelegate.m


#import "AppDelegate.h"

#import "ViewController.h"

#import "SecondViewController.h"

#import "ThirdViewController.h"

#import "FourViewController.h"

@interface AppDelegate ()

@end

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    // Override point for customization after application launch.



    ViewController *v1 = [[ViewController alloc]init];

    UINavigationController *nav1 = [[UINavigationController alloc]initWithRootViewController:v1];

    UITabBarItem *item1 = [[UITabBarItem alloc]initWithTitle:@"外卖" image:[UIImage imageNamed:@"menu_ico_shop_26x26_@3x"] selectedImage:[UIImage imageNamed:@"menu_ico_shop_on_26x26_@3x"]];

    nav1.tabBarItem = item1;


    SecondViewController *s1 = [[SecondViewController alloc]init];

    UINavigationController *nav2 = [[UINavigationController alloc]initWithRootViewController:s1];

    UITabBarItem *item2 = [[UITabBarItem alloc]initWithTitle:@"发现" image:[UIImage imageNamed:@"menu_ico_gather_26x26_@3x"] selectedImage:[UIImage imageNamed:@"menu_ico_gather_on_26x26_@3x"]];

    nav2.tabBarItem = item2;


    ThirdViewController *t1 = [[ThirdViewController alloc]init];

    UINavigationController *nav3 = [[UINavigationController alloc]initWithRootViewController:t1];

    UITabBarItem *item3 = [[UITabBarItem alloc]initWithTitle:@"订单" image:[UIImage imageNamed:@"ico_share_wechat_26x26_@3x"] selectedImage:[UIImage imageNamed:@"ico_share_wechat_on_26x26_@3x"]];

    nav3.tabBarItem = item3;


    FourViewController *f1 = [[FourViewController alloc]init];

    UINavigationController *nav4 = [[UINavigationController alloc]initWithRootViewController:f1];

    UITabBarItem *item4 = [[UITabBarItem alloc]initWithTitle:@"我的" image:[UIImage imageNamed:@"menu_ico_center_26x26_@3x"] selectedImage:[UIImage imageNamed:@"menu_ico_center_on_26x26_@3x"]];

    nav4.tabBarItem = item4;


    UITabBarController *tabbar = [[UITabBarController alloc]init];

    tabbar.viewControllers = @[nav1,nav2,nav3,nav4];

    self.window.rootViewController = tabbar;




    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 invalidate graphics rendering callbacks. 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 active 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:.

}

@end


TwoBtn.m


#import "TwoBtn.h"

@implementation TwoBtn

//调整title的位置

- (CGRect)titleRectForContentRect:(CGRect)contentRect

{

    CGRect rect;

    CGFloat titleW = contentRect.size.width;

    CGFloat titleH = 20;

    CGFloat titleX = 10;

    CGFloat titleY = 60;

    rect = CGRectMake(titleX, titleY, titleW, titleH);

    return rect;

}

//调整image的位置

- (CGRect)imageRectForContentRect:(CGRect)contentRect

{

    CGRect rect;

    CGFloat imageW = 50;

    CGFloat imageH = 50;

    CGFloat imageX = 15;

    CGFloat imageY = 0;

    rect = CGRectMake(imageX, imageY, imageW, imageH);

    return rect;



}

@end


MyButton.m


#import "MyButton.h"

@implementation MyButton

//调整title的位置

- (CGRect)titleRectForContentRect:(CGRect)contentRect

{

    CGRect rect;

    CGFloat titleW = 100;

    CGFloat titleH = 30;

    CGFloat titleX = 10;

    CGFloat titleY = 15;

    rect = CGRectMake(titleX, titleY, titleW, titleH);

    return rect;

}

//调整image的位置

- (CGRect)imageRectForContentRect:(CGRect)contentRect

{

    CGRect rect;

    CGFloat imageW = 50;

    CGFloat imageH = 50;

    CGFloat imageX = 130;

    CGFloat imageY = 8;

    rect = CGRectMake(imageX, imageY, imageW, imageH);

    return rect;

}

@end


OneTableViewCell.m


#import "OneTableViewCell.h"

@implementation OneTableViewCell

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

{

    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {

        [self CustomUi];

    }

    return self;

}

- (void)CustomUi

{

    UIView *views = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 414, 180)];

    views.backgroundColor = [UIColor colorWithRed:27/255.0 green:154/255.0 blue:252/255.0 alpha:1.0];

    [self.contentView addSubview:views];


    UILabel *labels = [[UILabel alloc]initWithFrame:CGRectMake(10, 20, 200, 50)];

    labels.text = @"饿了就要饿了么";

    labels.textColor = [UIColor whiteColor];

    labels.font = [UIFont systemFontOfSize:28 weight:2.0];

    [views addSubview:labels];


    UILabel *labelss = [[UILabel alloc]initWithFrame:CGRectMake(350, 28, 30, 20)];

    labelss.textColor = [UIColor whiteColor];

    labelss.text = @"33°";

    labelss.font = [UIFont systemFontOfSize:13];

    [views addSubview:labelss];


    UILabel *labelsss = [[UILabel alloc]initWithFrame:CGRectMake(358, 41, 20, 20)];

    labelsss.textColor = [UIColor whiteColor];

    labelsss.text = @"阴";

    labelsss.font = [UIFont systemFontOfSize:11];

    [views addSubview:labelsss];


    UILabel *labelssss = [[UILabel alloc]initWithFrame:CGRectMake(380, 26, 40, 40)];

    labelssss.textColor = [UIColor whiteColor];

    labelssss.text = @"☁️";

    labelssss.font = [UIFont systemFontOfSize:15];

    [views addSubview:labelssss];


    UILabel *labelsT = [[UILabel alloc]initWithFrame:CGRectMake(10, 75, 200, 20)];

    labelsT.text = @"❤ 八维研修学院(第二校区) ▼";

    labelsT.textColor = [UIColor whiteColor];

    labelsT.font = [UIFont systemFontOfSize:13];

    [views addSubview:labelsT];


    UITextField *textF = [[UITextField alloc]initWithFrame:CGRectMake(8, 103, 398, 40)];

    textF.text = @"🔍输入商家、商品名称";

    textF.textAlignment = NSTextAlignmentCenter;

    textF.backgroundColor = [UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0];

    textF.textColor = [UIColor grayColor];

    textF.font = [UIFont systemFontOfSize:13];

    textF.layer.cornerRadius = 15;

    textF.layer.masksToBounds = YES;

    [views addSubview:textF];


    CGFloat width = 50;

    CGFloat X = 10;

    NSArray *array = [NSArray array];

    array = @[@"西瓜",@"醉唐轩",@"三元",@"加班食补",@"我的菜",@"红烧肉",@"肯德基",@"庆丰"];

    for (int i = 0; i < 8 ; i ++) {

        UILabel *labelTT = [[UILabel alloc]initWithFrame:CGRectMake((X+width)*i, 150, width, 20)];

        labelTT.text = array[i];

        labelTT.textColor = [UIColor whiteColor];

        labelTT.font = [UIFont systemFontOfSize:12];

        [views addSubview:labelTT];

    }

}

@end


TwoTableViewCell.m


#import "TwoTableViewCell.h"

#import "MyButton.h"

#import "TwoBtn.h"

@implementation TwoTableViewCell

{

    TwoBtn *btn1;

    TwoBtn *btn2;

    TwoBtn *btn3;

    TwoBtn *btn4;

    TwoBtn *btn5;

    TwoBtn *btn6;

    TwoBtn *btn7;

}

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

{

    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {

        [self setUI];

    }

    return self;

}

- (void)setUI

{

    btn1 = [[TwoBtn alloc]initWithFrame:CGRectMake(15, 10, 60, 60)];

    btn1.titleEdgeInsets = UIEdgeInsetsMake(80, 0, 0, 0);

    btn1.titleLabel.textAlignment = NSTextAlignmentCenter;

    [btn1 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];

    btn1.titleLabel.font = [UIFont systemFontOfSize:13];

    [btn1 setTitle:@"汉堡薯条" forState:UIControlStateNormal];

    [btn1 setImage:[UIImage imageNamed:@"Food2"] forState:UIControlStateNormal];


    btn2 = [[TwoBtn alloc]initWithFrame:CGRectMake(115, 10, 60, 60)];

    btn2.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 50, 10);

    btn2.titleEdgeInsets = UIEdgeInsetsMake(80, 0, 0, 0);

    btn2.titleLabel.textAlignment = NSTextAlignmentCenter;

    [btn2 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];

    btn2.titleLabel.font = [UIFont systemFontOfSize:13];

    btn2.titleLabel.textAlignment = NSTextAlignmentCenter;

    [btn2 setTitle:@"包子粥店" forState:UIControlStateNormal];

    [btn2 setImage:[UIImage imageNamed:@"Food3"] forState:UIControlStateNormal];


    btn3 = [[TwoBtn alloc]initWithFrame:CGRectMake(215, 10, 60, 60)];

    btn3.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 50, 10);

    btn3.titleEdgeInsets = UIEdgeInsetsMake(80, 0, 0, 0);

    [btn3 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];

    btn3.titleLabel.font = [UIFont systemFontOfSize:13];

    btn3.titleLabel.textAlignment = NSTextAlignmentCenter;

    [btn3 setTitle:@"鲜花蛋糕" forState:UIControlStateNormal];

    [btn3 setImage:[UIImage imageNamed:@"Food4"] forState:UIControlStateNormal];


    btn4 = [[TwoBtn alloc]initWithFrame:CGRectMake(315, 10, 60, 60)];

    btn4.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 50, 10);

    btn4.titleEdgeInsets = UIEdgeInsetsMake(80, 0, 0, 0);

    [btn4 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];

    btn4.titleLabel.font = [UIFont systemFontOfSize:13];

    btn4.titleLabel.textAlignment = NSTextAlignmentCenter;

    [btn4 setTitle:@"麻辣烫" forState:UIControlStateNormal];

    [btn4 setImage:[UIImage imageNamed:@"Food5"] forState:UIControlStateNormal];


    btn5 = [[TwoBtn alloc]initWithFrame:CGRectMake(15, 100, 60, 60)];

    btn5.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 50, 10);

    btn5.titleEdgeInsets = UIEdgeInsetsMake(80, 0, 0, 0);

    [btn5 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];

    btn5.titleLabel.font = [UIFont systemFontOfSize:13];

    btn5.titleLabel.textAlignment = NSTextAlignmentCenter;

    [btn5 setTitle:@"地方菜" forState:UIControlStateNormal];

    [btn5 setImage:[UIImage imageNamed:@"Food5"] forState:UIControlStateNormal];


    btn6 = [[TwoBtn alloc]initWithFrame:CGRectMake(115, 100, 60, 60)];

    btn6.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 50, 10);

    btn6.titleEdgeInsets = UIEdgeInsetsMake(80, 0, 0, 0);

    [btn6 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];

    btn6.titleLabel.font = [UIFont systemFontOfSize:13];

    btn6.titleLabel.textAlignment = NSTextAlignmentCenter;

    [btn6 setTitle:@"披萨意面" forState:UIControlStateNormal];

    [btn6 setImage:[UIImage imageNamed:@"Food5"] forState:UIControlStateNormal];


    btn7 = [[TwoBtn alloc]initWithFrame:CGRectMake(215, 100, 60, 60)];

    btn7.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 50, 10);

    btn7.titleEdgeInsets = UIEdgeInsetsMake(80, 0, 0, 0);

    [btn7 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];

    btn7.titleLabel.font = [UIFont systemFontOfSize:13];

    btn7.titleLabel.textAlignment = NSTextAlignmentCenter;

    [btn7 setTitle:@"异国料理" forState:UIControlStateNormal];

    [btn7 setImage:[UIImage imageNamed:@"Food5"] forState:UIControlStateNormal];



    [self.contentView addSubview:btn1];

    [self.contentView addSubview:btn2];

    [self.contentView addSubview:btn3];

    [self.contentView addSubview:btn4];

    [self.contentView addSubview:btn5];

    [self.contentView addSubview:btn6];

    [self.contentView addSubview:btn7];

//    CGFloat width = 60;

//    CGFloat height = 60;

//    CGFloat X = 10+width;

//    NSArray *array = [NSArray array];

//    array = @[@"汉堡薯条",@"包子粥店",@"鲜花蛋糕",@"麻辣烫"];

//    NSArray *arrays = [NSArray array];

//    arrays = @[@"Food1",@"Food2",@"Food3",@"Food4"];

//    for (int i = 0; i < 4; i ++) {

//        MyButton *btns =[[MyButton alloc]initWithFrame:CGRectMake(X*i, 20, width, height)];

//        [btns setImage:[UIImage imageNamed:arrays[i]] forState:UIControlStateNormal];

//        [btns setTitle:array[i] forState:UIControlStateNormal];

//        [btns setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];

//        btns.titleLabel.font = [UIFont systemFontOfSize:13];

//        btns.titleLabel.textAlignment = NSTextAlignmentCenter;

//        [self.contentView addSubview:btns];

//    }

}

@end


ThreeTableViewCell.m


#import "ThreeTableViewCell.h"

@implementation ThreeTableViewCell

{

    //实现三个属性

    UIScrollView *scroll;

    NSArray *imgArr;//图片

    UIPageControl *page;//页面

}

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

{

    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {

        [self CustomUI];

    }

    return self;

}

- (void)CustomUI

{

    scroll = [[UIScrollView alloc]initWithFrame:CGRectMake(8, 5, 398, 100)];

    [self.contentView addSubview:scroll];


    imgArr = @[@"切片1",@"899724a811384b1c24b081ba456df08f.jpg.png",@"b7d69dc73c527365a8826b0d753aaea7.jpg"];

    //设置图片进行滚动

    scroll.pagingEnabled = YES;

    for (int i = 0; i < imgArr.count; i++)

    {

        UIImageView *img = [[UIImageView alloc]initWithFrame:CGRectMake(398 * i, 0, 398, 100)];

        img.userInteractionEnabled = YES;

        img.image = [UIImage imageNamed:imgArr[i]];

        [scroll addSubview:img];

    }

    scroll.contentSize = CGSizeMake(398 * imgArr.count, 100);

    //取消弹簧效果

    scroll.bounces = NO;

    //隐藏滚动条

    scroll.showsHorizontalScrollIndicator = NO;

    //页码  (点)

    page = [[UIPageControl alloc]initWithFrame:CGRectMake((398 -100) / 2, 80, 100, 20)];

    page.numberOfPages = imgArr.count;

    //设置初始页码

    page.currentPage = 0;

    //设置页码的颜色

    page.pageIndicatorTintColor = [UIColor grayColor];

    [self.contentView addSubview:page];

//    UIImageView *images = [[UIImageView alloc]initWithFrame:CGRectMake(8, 5, 398, 100)];

//    images.image = [UIImage imageNamed:@"切片1"];

//    [self.contentView addSubview:images];

//

    UIView *views = [[UIView alloc]initWithFrame:CGRectMake(0, 110, 414, 8)];

    views.backgroundColor = [UIColor colorWithRed:243/255.0 green:243/255.0 blue:243/255.0 alpha:1.0];

    [self.contentView addSubview:views];

}

-(void)scrollViewDidScroll:(UIScrollView *)scrollView

{

    NSLog(@"contentOffset: x: %f,y: %f",scrollView.contentOffset.x,scrollView.contentOffset.y);

    //求余

    NSInteger index = scroll.contentOffset.x / scrollView.frame.size.width;

    page.currentPage = index;

}

@end


FourTableViewCell.m


#import "FourTableViewCell.h"

#import "MyButton.h"

@implementation FourTableViewCell

{

    MyButton *buttom1;

    MyButton *buttom2;

    MyButton *buttom3;

    MyButton *buttom4;

}

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

{

    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {

        [self customUI];

    }

    return self;

}

- (void)customUI

{

    self.backgroundColor = [UIColor colorWithRed:243/255.0 green:243/255.0 blue:243/255.0 alpha:1.0];


    buttom1 = [[MyButton alloc]initWithFrame:CGRectMake(0, 0, 206, 75)];

    buttom1.backgroundColor = [UIColor whiteColor];

    buttom1.titleLabel.textAlignment = NSTextAlignmentCenter;

    [buttom1 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];

    buttom1.titleLabel.font = [UIFont systemFontOfSize:15 weight:2];

    [buttom1 setTitle:@"四星晚餐" forState:UIControlStateNormal];

    [buttom1 setImage:[UIImage imageNamed:@"Food1"] forState:UIControlStateNormal];

    [self.contentView addSubview:buttom1];

    UILabel *label1 = [[UILabel alloc]initWithFrame:CGRectMake(28, 40, 100, 20)];

    label1.text = @"满40减20起";

    label1.textColor = [UIColor lightGrayColor];

    label1.font = [UIFont systemFontOfSize:12];

    [buttom1 addSubview:label1];


    buttom2 = [[MyButton alloc]initWithFrame:CGRectMake(207, 0, 207, 75)];

    buttom2.backgroundColor = [UIColor whiteColor];

    buttom2.titleLabel.textAlignment = NSTextAlignmentCenter;

    [buttom2 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];

    buttom2.titleLabel.font = [UIFont systemFontOfSize:15 weight:2];

    [buttom2 setTitle:@"霸王餐" forState:UIControlStateNormal];

    [buttom2 setImage:[UIImage imageNamed:@"Food2"] forState:UIControlStateNormal];


    [self.contentView addSubview:buttom2];


    UILabel *label2 = [[UILabel alloc]initWithFrame:CGRectMake(35, 40, 100, 20)];

    label2.text = @"领20元红包";

    label2.textColor = [UIColor lightGrayColor];

    label2.font = [UIFont systemFontOfSize:12];

    [buttom2 addSubview:label2];


    buttom3 = [[MyButton alloc]initWithFrame:CGRectMake(0, 76, 206, 75)];

    buttom3.backgroundColor = [UIColor whiteColor];

    buttom3.titleLabel.textAlignment = NSTextAlignmentCenter;

    [buttom3 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];

    buttom3.titleLabel.font = [UIFont systemFontOfSize:15 weight:2];

    [buttom3 setTitle:@"快选加班餐" forState:UIControlStateNormal];

    [buttom3 setImage:[UIImage imageNamed:@"Food3"] forState:UIControlStateNormal];


    [self.contentView addSubview:buttom3];


    UILabel *label3 = [[UILabel alloc]initWithFrame:CGRectMake(28, 40, 100, 20)];

    label3.text = @"低至5折";

    label3.textColor = [UIColor lightGrayColor];

    label3.font = [UIFont systemFontOfSize:12];

    [buttom3 addSubview:label3];


    buttom4 = [[MyButton alloc]initWithFrame:CGRectMake(207, 76, 207, 75)];

    buttom4.backgroundColor = [UIColor whiteColor];

    buttom4.titleLabel.textAlignment = NSTextAlignmentCenter;

    [buttom4 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];

    buttom4.titleLabel.font = [UIFont systemFontOfSize:15 weight:2];

    [buttom4 setTitle:@"立减10元" forState:UIControlStateNormal];

    [buttom4 setImage:[UIImage imageNamed:@"Food4"] forState:UIControlStateNormal];


    [self.contentView addSubview:buttom4];


    UILabel *label4 = [[UILabel alloc]initWithFrame:CGRectMake(35, 40, 100, 20)];

    label4.text = @"周二开胃菜";

    label4.textColor = [UIColor lightGrayColor];

    label4.font = [UIFont systemFontOfSize:12];

    [buttom4 addSubview:label4];


}

@end


ViewController.m


#import "ViewController.h"#import "OneTableViewCell.h"#import "TwoTableViewCell.h"#import "ThreeTableViewCell.h"#import "FourTableViewCell.h"static NSString *cellid = @"deliciousCell";static NSString *cellids = @"functionCell";static NSString *cellidss = @"menucell";static NSString *contentid = @"contentcell";@interface ViewController ()@property (nonatomic,strong)UITableView *tables;

@end

@implementation ViewController

- (void)viewDidLoad {

    [super viewDidLoad];

    self.view.backgroundColor = [UIColor whiteColor];

    self.navigationController.navigationBarHidden = YES;

    [self tables];

}

- (UITableView *)tables

{

    if (!_tables) {

        _tables = [[UITableView alloc]initWithFrame:self.view.frame style:UITableViewStylePlain];

        _tables.delegate = self;

        _tables.dataSource = self;

        [_tables registerClass:[OneTableViewCell class] forCellReuseIdentifier:cellid];

        [_tables registerClass:[TwoTableViewCell class] forCellReuseIdentifier:cellids];

        [_tables registerClass:[ThreeTableViewCell class] forCellReuseIdentifier:cellidss];

        [_tables registerClass:[FourTableViewCell class] forCellReuseIdentifier:contentid];

        [self.view addSubview:_tables];

    }

    return _tables;

}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView

{

    return 4;

}

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

{

    return 1;

}

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

{

    UITableViewCell *cell;

    switch (indexPath.section)

    {

        case 0:{

            OneTableViewCell *Ocells = [tableView dequeueReusableCellWithIdentifier:cellid];

            if (!Ocells) {

                Ocells = [[OneTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellid];

            }

            return Ocells;

        }

            break;

        case 1:{

            TwoTableViewCell *Tcells = [tableView dequeueReusableCellWithIdentifier:cellids];

            if (!Tcells) {

                Tcells = [[TwoTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellids];

            }

            return Tcells;

        }

            break;

        case 2:{

            ThreeTableViewCell *Ttcells = [tableView dequeueReusableCellWithIdentifier:cellidss];

            if (!Ttcells) {

                Ttcells = [[ThreeTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellidss];

            }

            return Ttcells;

        }

            break;

        case 3:

        {

            FourTableViewCell *fcells = [tableView dequeueReusableCellWithIdentifier:contentid];

            if (!fcells) {

                fcells = [[FourTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:contentid];

            }

            return fcells;

        }

            break;

        default:

        {

            cell = [tableView dequeueReusableCellWithIdentifier:@""];

            if (!cell)

            {

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

            }

        }

            break;

    }

    return cell;

}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

{

    if (indexPath.section == 0) {

        return 180;

    }

    else if (indexPath.section ==1){

        return 180;

    }

    else if (indexPath.section == 2){

        return 119;

    }

    else if (indexPath.section == 3){

        return 158;

    }

    return 0;

}

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

{

    [_tables deselectRowAtIndexPath:indexPath animated:YES];

}

@end


SecondViewController.m

ThirdViewController.m

FourViewController.m


self.view.backgroundColor = [UIColor whiteColor];


最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 203,937评论 6 478
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,503评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 150,712评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,668评论 1 276
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,677评论 5 366
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,601评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,975评论 3 396
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,637评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,881评论 1 298
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,621评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,710评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,387评论 4 319
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,971评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,947评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,189评论 1 260
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 44,805评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,449评论 2 342

推荐阅读更多精彩内容