123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299 |
- #import "LearnDrivingVC.h"
- #import "MyUINavigationController.h"
- #import "CommunityVC.h"
- #import "DiaryVC.h"
- #import "CLCell.h"
- #import "LoginViewController.h"
- #import "TopicesVC.h"
- #import "NewsOfLearnVC.h"
- //#import "RecordOfLearnVC.h"
- #import "GuideVC.h"
- #import "CoachDetailInfoVC.h"
- #import "ShareVC.h"
- @interface LearnDrivingVC ()<UITableViewDataSource,UITableViewDelegate>
- {
- UITableView* myTableView;
-
- NSMutableArray* titles;
- NSMutableArray* images;
- NSMutableArray* details;
-
- NSMutableArray *countArray;
- }
- @end
- @implementation LearnDrivingVC
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self myInit];
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated
- }
- -(void)viewWillAppear:(BOOL)animated
- {
- [super viewWillAppear:animated];
- [self getCurrentTopicTj];
- }
- -(void)viewWillDisappear:(BOOL)animated{
- [self setHidesBottomBarWhenPushed:NO];
- [super viewWillDisappear:animated];
- }
- #pragma mark -
- -(void)myInit
- {
- self.navigationItem.title = @"学车社区";
- [self.view setBackgroundColor:backGroundColor];
- countArray = [NSMutableArray alloc];
-
- titles = [NSMutableArray array];
- images = [NSMutableArray array];
- details = [NSMutableArray array];
-
- NSArray* arr;
- arr = @[@"驾考社区",@"驾考头条",@"学车指南"];
- [titles addObject:arr];
- arr = @[@"学车记录",@"学车问答",@"我的学车日记"];//@"学车直播",
- [titles addObject:arr];
- arr = @[@"我的教练"];
- [titles addObject:arr];
-
- arr = @[@"learn_img01.png",@"learn_img02.png",@"learn_img03.png"];
- [images addObject:arr];
- arr = @[@"learn_img04.png",@"learn_img06.png"];
- [images addObject:arr];
- arr = @[@"learn_img07.png",@"learn_img08.png",@"learn_img09.png"];
- [images addObject:arr];
-
-
- arr = @[[NSString stringWithFormat:@"%d人参与讨论",arc4random()%100],[NSString stringWithFormat:@"%d万人正在关注",arc4random()%7],@"",@"",@""];
- [details addObject:arr];
-
- arr = @[[NSString stringWithFormat:@"有%d人在学车",arc4random()%100],[NSString stringWithFormat:@"有%d人参与问答",arc4random()%100],@"",@""];//,[NSString stringWithFormat:@"有%d人参与直播",arc4random()%100]
- [details addObject:arr];
- arr = @[@"",@"",@""];
- [details addObject:arr];
-
- myTableView = [[UITableView alloc] initWithFrame:kFrame style:UITableViewStyleGrouped];
- myTableView.height -= kTabBarHeight;
- [self.view addSubview:myTableView];
- [myTableView setDelegate:self];
- [myTableView setDataSource:self];
- myTableView.estimatedSectionHeaderHeight = 0;
- myTableView.estimatedSectionFooterHeight = 0;
- }
- #pragma mark -
- -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
- {
- return .1;
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
- {
- return 10;
- }
- -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- {
- return titles.count;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- NSArray *array = titles[section];
- return [array count];
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- NSString* reuseID = @"learningCell";
- UITableViewCell* cell;
- if (!cell) {
- cell = [[CLCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:reuseID];
- [cell.detailTextLabel setFont:[UIFont scaleSize:13]];
- [cell.textLabel setTextColor:contentTextColor];
- [cell.textLabel setFont:[UIFont scaleSize:15]];
- }
- [cell.textLabel setText:[titles objAtPath:indexPath] ];
- if (indexPath.section == 1 && indexPath.row == 2)
- {
- [cell.textLabel setTextAlignment:NSTextAlignmentCenter];
- [cell.textLabel setTextColor:contentTextColor];
- return cell;
- }
-
- [cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];
- UIImage* img = [UIImage imageNamed:[images objAtPath:indexPath] ];
- [cell.imageView setImage:img];
- [cell.detailTextLabel setText:[details objAtPath:indexPath] ];
-
- return cell;
- }
- -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- [tableView deselectRowAtIndexPath:indexPath animated:YES];
-
- if (0 == indexPath.section) {
- if (0 == indexPath.row) {
- CommunityVC* vc = [[CommunityVC alloc] init];
- [self navPushHideTabbarToVC:vc];
- }
- if (1 == indexPath.row) {
-
- // ShareVC* vc = [[ShareVC alloc] init];
- // [self navPushHideTabbarToVC:vc];
- // 驾考头条 这里改为驾考新闻 直接进入新闻页面
- NewsOfLearnVC* vc = [[NewsOfLearnVC alloc] init];
- [self navPushHideTabbarToVC:vc];
- }
- if (2 == indexPath.row) {
- GuideVC* vc = [[GuideVC alloc] init];
- [self navPushHideTabbarToVC:vc];
- }
- }
- if (1 == indexPath.section)
- {
- if (0 == indexPath.row) {
- // RecordOfLearnVC* vc = [[RecordOfLearnVC alloc] init];
- TopicesVC* vc = [[TopicesVC alloc] init];
- vc.type = @"2";
- vc.groupId = @"";
- vc.childID = @"";
- [self navPushHideTabbarToVC:vc];
- }
- // if (1 == indexPath.row) {
- // TopicesVC* vc = [[TopicesVC alloc] init];
- // vc.type = @"3";
- // [self navPushHideTabbarToVC:vc];
- // }
- if (1 == indexPath.row) {
- TopicesVC* vc = [[TopicesVC alloc] init];
- vc.type = @"4";
- [self navPushHideTabbarToVC:vc];
- }
- if (2 == indexPath.row)
- {
- if (!myDelegate.isLogin) {
- [LoginViewController loginFromVC:self];
- return;
- }
- DiaryVC* vc = [[DiaryVC alloc] init];
- vc.userID = defUser.userDict[@"id"];
- [self navPushHideTabbarToVC:vc];
- }
- }
- if (2 == indexPath.section) {
-
- if (myDelegate.isLogin) {
- CoachDetailInfoVC* vc = [[CoachDetailInfoVC alloc] init];
- MyUINavigationController* nav = [[MyUINavigationController alloc] initWithRootViewController:vc];
- nav.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
- nav.modalPresentationStyle = UIModalPresentationFullScreen;
- [self.parentViewController presentViewController:nav animated:YES completion:nil];
- }else{
- ShowMsg(@"请登录后再操作!");
- [LoginViewController loginFromVC:self];
- }
- }
- }
- #pragma mark -
- /**
- */
- -(void)getCurrentTopicTj
- {
- if (![Util connectedToNetWork]) {
- showMsgUnconnect();
- return;
- }
-
- NSString* method = @"getCurrentTopicTj";
- [jiaPeiManager requestGetAnythingWithURL:method completion:^(NSDictionary *dict) {
-
- //NSLog(@"getCurrentTopicTj%@",dict);
- if (!dict) {
- ShowMsgFailed();
- return;
- }
- if ([dict[@"code"] isEqualToString:@"1"]) {
- ShowMsg(dict[@"body"]);
- return;
- }
-
- NSDictionary *dic = dict[@"body"];
- if (dic && [[dic allKeys] count] > 0)
- {
- [details removeAllObjects];
- NSArray *arr;
-
- arr = @[[NSString stringWithFormat:@"%@人参与话题",[self isWan:dic[@"COMMENTNUM"]]],[NSString stringWithFormat:@"%@人正在关注",[self isWan:dic[@"READNUM"]]],@"",@"",@""];
- if ([dic[@"COMMENTNUM"] isEqualToString:@""])
- {
- arr = @[[NSString stringWithFormat:@"0人参与话题"],[NSString stringWithFormat:@"%@人正在关注",[self isWan:dic[@"READNUM"]]],@"",@"",@""];
- if ([dic[@"READNUM"] isEqualToString:@""])
- {
- arr = @[[NSString stringWithFormat:@"0人参与话题"],[NSString stringWithFormat:@"0人正在关注"],@"",@"",@""];
- }
- }
- else
- {
- if ([dic[@"READNUM"] isEqualToString:@""])
- {
- arr = @[[NSString stringWithFormat:@"%@人参与话题",[self isWan:dic[@"COMMENTNUM"]]],[NSString stringWithFormat:@"0人正在关注"],@"",@"",@""];
- }
- }
-
- [details addObject:arr];
-
- NSString *xc = dic[@"TOPICNUM"];
- NSString *zb = dic[@"ZB"];
- NSString *wd = dic[@"WD"];
-
- if ([dic[@"TOPICNUM"] isEqualToString:@""]) {
- xc = @"0";
- }
- if ([dic[@"ZB"] isEqualToString:@""]) {
- zb = @"0";
- }
- if ([dic[@"WD"] isEqualToString:@""]) {
- wd = @"0";
- }
- arr = @[[NSString stringWithFormat:@"有%@人在学车",[self isWan:xc]],[NSString stringWithFormat:@"有%@人参与直播",[self isWan:zb]],[NSString stringWithFormat:@"有%@人参与问答",[self isWan:wd]],@"",@"",@""];
-
- [details addObject:arr];
- arr = @[@"",@"",@""];
- [details addObject:arr];
-
- [myTableView reloadData];
- }
- }];
- }
- //将超过四位的万位数 改写为x.x万
- -(NSString *)isWan:(NSString *)string
- {
- NSString *newString = string;
- if (string.length > 4) {
-
- newString = [NSString stringWithFormat:@"%@.%@万",[string substringToIndex:string.length - 4],[string substringWithRange:NSMakeRange(string.length - 4, 1)]];
- }
- //NSLog(@"newString---->%@",newString);
- return newString;
- }
- @end
|