123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- //
- #import "FavTopicsVC.h"
- #import "FavCell.h"
- #import "TopicVC.h"
- @interface FavTopicsVC ()<UITableViewDataSource,UITableViewDelegate>
- {
- UITableView* myTableView;
-
- NSArray* models;
-
- /**每次下载后。就判断.
- 如果cnt为0就显示。否则隐藏
- */
- UIView* placeHolder;
- }
- @end
- @implementation FavTopicsVC
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self myInit];
- [self getMyTopicFavs];
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- -(void)viewDidAppear:(BOOL)animated
- {
- [super viewDidAppear:animated];
- }
- #pragma mark -
- -(void)myInit
- {
- [self configNavigationBar];
- [self setTitle:@"收藏"];
-
- //这是一个请求为空的界面 教练列表可以放一个
- UITableView* tv = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, kSize.width, kSize.height - kNavOffSet)];
- [self.view addSubview:tv];
- myTableView = tv;
- [myTableView setDelegate:self];
- [myTableView setDataSource:self];
- [tv setTableFooterView:[UIView new]];
-
- CGFloat x,y,w,h;
- y = 0;
- //placeHolder
- UIView* vi = [[UIView alloc] initWithFrame:CGRectMake(0, y, kSize.width, kSize.height - y - kNavOffSet)];
- [self.view addSubview:vi];
- vi.hidden = YES;
- placeHolder = vi;
-
- w = h = kSize.width/3.0;
- x = y = w;
- UIImageView* iv = [[UIImageView alloc] initWithFrame:CGRectMake(x, y, w, h)];
- [iv setImage:[UIImage imageNamed:@"community4.png"]];
- [iv setContentMode:UIViewContentModeScaleAspectFit];
- [placeHolder addSubview:iv];
-
- y += h + 20;
- x = 0;
- w = kSize.width;
- h = 40;
- UILabel* label = [[UILabel alloc] initWithFrame:CGRectMake(x, y, w, h)];
- [label setText:@"您还没有收藏话题呢~"];
- [label setTextAlignment:NSTextAlignmentCenter];
- [label setTextColor:contentTextColor];
- [placeHolder addSubview:label];
- }
- #pragma mark -
- -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- return FavCellHeightByDict(models[indexPath.row]);
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return models.count;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- FavCell* cell = [FavCell cellForTableView:tableView];
- [cell setModel:models[indexPath.row]];
- return cell;
- }
- -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
- [tableView deselectRowAtIndexPath:indexPath animated:YES];
- NSDictionary * obj = models[indexPath.row];
-
- TopicVC* vc = [[TopicVC alloc] init];
- [vc setTopicId:obj[@"ID"]];
- vc.userId = obj[@"TI_CRUSER"];
- [self navPushHideTabbarToVC:vc];
- }
- #pragma mark -
- -(void)getMyTopicFavs
- {
- if (![Util connectedToNetWork]) {
- showMsgUnconnect();
- return;
- }
-
- placeHolder.hidden = NO;
-
- NSMutableArray *arr=[NSMutableArray array];
- [arr addPro:@"user" Value:defUser.userDict[@"id"]];
- [arr addPro:@"isPage" Value:@"1"];
- [arr addPro:@"pageSize" Value:@"10"];
- [arr addPro:@"currentPage" Value:@"1"];
- NSString* method = @"getMyTopicFavs";
- [MBProgressHUD showLoadToView:self.view];
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *dict) {
-
- [MBProgressHUD hideHUDForView:self.view];
- //NSLog(@"收藏列表---->%@",dict);
- if (!dict) {
- ShowMsgFailed();
- return;
- }
- if ( [dict[@"code"] isEqualToString:@"1"]) {
- ShowMsg(dict[@"body"]);
- return;
- }
-
- NSArray* json = dict[@"body"];
- models = json;
- if (json.count != 0) {
- placeHolder.hidden = YES;
- }
-
- [myTableView reloadData];
- }];
- }
- @end
|