开春大礼《华为云技术精选集》大厂100+前沿技术实战分享!>>>
//
// ViewController.m
// ios-TabelView
//
// Created by ma c on 15/8/28.
// Copyright (c) 2015年 sxt. All rights reserved.
//
#import "ViewController.h"
#import "Second.h"
@interface ViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (weak, nonatomic) IBOutlet UITableView *tabelView;
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// self.view.backgroundColor = [UIColor whiteColor];
//设置数据源的两种方法
//1·代码设置
//2·拖线
self.tabelView.dataSource = self;
self.view.backgroundColor = [UIColor whiteColor];
}
- (BOOL)prefersStatusBarHidden
{
return YES;
}
/**
有两组
*/
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// NSLog(@"numberOfRowsInSection-%d", section);
/**从上面可知,有两组,所有由这里判断,第0组有三行,第二组有四行*/
if (section == 0) {
return 2;
} else {
return 2;
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
/**每组里面的每一行显示的内容*/
UITableViewCell *cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
if(indexPath.section == 0) //第一组--两行
{
if(indexPath.row==0)
cell.textLabel.text = @"奥迪";
else if(indexPath.row==1)
cell.textLabel.text =@"奔驰";
}else if(indexPath.section == 1)
{
if (indexPath.row == 0) {
cell.textLabel.text = @"法拉利";
}else if (indexPath.row == 1)
cell.textLabel.text = @"兰博基尼";
}
return cell;
}
/**显示section组的头部标题*/
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
if(section == 0)
return @"德系轿车";
else
return @"英系轿车";
}
/**显示section的尾部标题*/
- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section
{
if (section == 0) {
return @"宇宙第一品牌";
}else
return @"牛哄哄";
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"哈哈");
Second *se = [[Second alloc]init];
[self.navigationController pushViewController:se animated:YES];
}
@end
我的需求是实现点击行 跳转到second上面去 ,second是继承UIViewController的,但是跳不过去是怎么回事,代理已经构建完成,拖的线???? 我还是ios菜鸟求解释!!!!! 急急急!!!!!