pli

ViewController


#import "ViewController.h"

#import "Model.h"

#import "SecViewController.h"

@interface ViewController ()

{

    NSMutableArray *data1;

    UITableView *tab;

    Model *_model;

}

@end

@implementation ViewController

- (void)viewDidLoad {

    [super viewDidLoad];

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

    self.title=@"车型";

    self.view.backgroundColor = [UIColor whiteColor];


    NSString *filepath = [[NSBundle mainBundle]pathForResource:@"Property List" ofType:@".plist"];


    data1 = [[NSMutableArray alloc]initWithContentsOfFile:filepath];




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

    tab.rowHeight = 60;

    tab.dataSource = self;

    tab.delegate=self;

    [self.view addSubview:tab];


}

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

    returndata1.count;

}

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

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


    if(!cell) {

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


    }

    _model = [[Model alloc] init];

    NSDictionary*item = [data1objectAtIndex:indexPath.row];

    _model.title = [item objectForKey:@"title"];

    _model.tatext = [item objectForKey:@"tatext"];

    _model.image = [item objectForKey:@"image"];



    cell.textLabel.text = _model.title;

    cell.detailTextLabel.text = _model.tatext;

    cell.imageView.image = [UIImage imageNamed:_model.image];

    returncell;

}

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

    SecViewController *sec = [[SecViewController alloc] init];

    NSDictionary*item = [data1objectAtIndex:indexPath.row];

    _model.title = [item objectForKey:@"title"];

    _model.image = [item objectForKey:@"image"];

    sec.sd = _model.title;

    sec.img = _model.image;

    [self.navigationController pushViewController:sec animated:YES];

}


SecViewController.h


#import 

@interfaceSecViewController :UIViewController

@property(nonatomic,copy)NSString *img;

@property(nonatomic,copy)NSString *sd;

@end


SecViewController.m


#import "SecViewController.h"

@interface SecViewController ()

@end

@implementationSecViewController

- (void)viewDidLoad {

    [super viewDidLoad];


    self.view.backgroundColor = [UIColor whiteColor];

    self.navigationItem.title =_sd;

    UIImageView*image = [[UIImageViewalloc]initWithFrame:CGRectMake(60,100,300,250)];

    image.image= [UIImageimageNamed:_img];


    [self.viewaddSubview:image];

    // Do any additional setup after loading the view.

}


Model.h


#import

@interface Model : NSObject

@property(nonatomic,copy)NSString *title;

@property(nonatomic,copy)NSString *tatext;

@property(nonatomic,copy)NSString *image;

@end

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 一、简介 <<UITableView(或简单地说,表视图)的一个实例是用于显示和编辑分层列出的信息的一种手段 <<...
    无邪8阅读 13,685评论 3 3
  • 1.ios高性能编程 (1).内层 最小的内层平均值和峰值(2).耗电量 高效的算法和数据结构(3).初始化时...
    欧辰_OSR阅读 30,007评论 8 265
  • *7月8日上午 N:Block :跟一个函数块差不多,会对里面所有的内容的引用计数+1,想要解决就用__block...
    炙冰阅读 7,374评论 1 14
  • Swift1> Swift和OC的区别1.1> Swift没有地址/指针的概念1.2> 泛型1.3> 类型严谨 对...
    cosWriter阅读 13,887评论 1 32
  • 栈 栈:是一种具有特殊的访问方式的存储空间(后进先出, Last In Out Firt,LIFO) SP和FP寄...
    fanren阅读 4,208评论 0 0

友情链接更多精彩内容