Initial commit

This commit is contained in:
ifish
2017-08-15 16:59:01 +08:00
commit bdc83e07ef
5766 changed files with 423223 additions and 0 deletions
@@ -0,0 +1,16 @@
//
// UINavigationBar+Awesome.h
// LTNavigationBar
//
// Created by ltebean on 15-2-15.
// Copyright (c) 2015 ltebean. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UINavigationBar (ChangeBackgroundColor)
- (void)umcom_setBackgroundColor:(UIColor *)backgroundColor;
- (void)umcom_setElementsAlpha:(CGFloat)alpha;
- (void)umcom_setTranslationY:(CGFloat)translationY;
- (void)umcom_reset;
@end
@@ -0,0 +1,70 @@
//
// UINavigationBar+Awesome.m
// LTNavigationBar
//
// Created by ltebean on 15-2-15.
// Copyright (c) 2015 ltebean. All rights reserved.
//
#import "UINavigationBar+ChangeBackgroundColor.h"
#import <objc/runtime.h>
@implementation UINavigationBar (ChangeBackgroundColor)
static char UMComOverlayKey;
- (UIView *)overlayForNavigationBar
{
return objc_getAssociatedObject(self, &UMComOverlayKey);
}
- (void)setOverlayForNavigationBar:(UIView *)overlay
{
objc_setAssociatedObject(self, &UMComOverlayKey, overlay, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
- (void)umcom_setBackgroundColor:(UIColor *)backgroundColor
{
if (!self.overlayForNavigationBar) {
[self setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
self.overlayForNavigationBar = [[UIView alloc] initWithFrame:CGRectMake(0, -20, CGRectGetWidth(self.bounds), CGRectGetHeight(self.bounds) + 20)];
self.overlayForNavigationBar.userInteractionEnabled = NO;
self.overlayForNavigationBar.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
[self insertSubview:self.overlayForNavigationBar atIndex:0];
}
self.overlayForNavigationBar.backgroundColor = backgroundColor;
}
- (void)umcom_setTranslationY:(CGFloat)translationY
{
self.transform = CGAffineTransformMakeTranslation(0, translationY);
}
- (void)umcom_setElementsAlpha:(CGFloat)alpha
{
[[self valueForKey:@"_leftViews"] enumerateObjectsUsingBlock:^(UIView *view, NSUInteger i, BOOL *stop) {
view.alpha = alpha;
}];
[[self valueForKey:@"_rightViews"] enumerateObjectsUsingBlock:^(UIView *view, NSUInteger i, BOOL *stop) {
view.alpha = alpha;
}];
UIView *titleView = [self valueForKey:@"_titleView"];
titleView.alpha = alpha;
// when viewController first load, the titleView maybe nil
[[self subviews] enumerateObjectsUsingBlock:^(UIView *obj, NSUInteger idx, BOOL *stop) {
if ([obj isKindOfClass:NSClassFromString(@"UINavigationItemView")]) {
obj.alpha = alpha;
*stop = YES;
}
}];
}
- (void)umcom_reset
{
[self setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
[self.overlayForNavigationBar removeFromSuperview];
self.overlayForNavigationBar = nil;
}
@end
@@ -0,0 +1,19 @@
//
// UMComBriefEditView.h
// UMCommunity
//
// Created by 张军华 on 16/5/17.
// Copyright © 2016年 Umeng. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UMComBriefEditView : UITextView
@property(nonatomic,copy) NSString *placeholder; //文字
@property(nonatomic,strong) UIColor *placeholderColor; //文字颜色
@property(nonatomic,strong) UIFont *placeholderFont; //文字颜色
@end
@@ -0,0 +1,94 @@
//
// UMComBriefEditView.m
// UMCommunity
//
// Created by 张军华 on 16/5/17.
// Copyright © 2016年 Umeng. All rights reserved.
//
#import "UMComBriefEditView.h"
@interface UMComBriefEditView ()
@property (nonatomic,weak) UILabel *placeholderLabel; //这里先拿出这个label以方便我们后面的使用
@end
@implementation UMComBriefEditView
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if(self) {
//self.backgroundColor= [UIColor clearColor];
UILabel *placeholderLabel = [[UILabel alloc]init];//添加一个占位label
placeholderLabel.backgroundColor= [UIColor clearColor];
//只设置一行
placeholderLabel.numberOfLines=1; //设置可以输入多行文字时可以自动换行
[self addSubview:placeholderLabel];
self.placeholderLabel= placeholderLabel; //赋值保存
self.placeholderLabel.frame = CGRectMake(5, 0, frame.size.width, 30);
self.placeholderLabel.textColor= [UIColor lightGrayColor]; //设置占位文字默认颜色
self.placeholderLabel.font = [UIFont systemFontOfSize:14]; //设置默认的字体
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textDidChange) name:UITextViewTextDidChangeNotification object:self]; //通知:监听文字的改变
}
return self;
}
#pragma mark -监听文字改变
- (void)textDidChange {
if (self.text.length > 0) {
self.placeholderLabel.hidden = YES;
}
else
{
self.placeholderLabel.hidden = NO;
}
//self.hasText频繁调用会崩溃(原因还没有查到!!!)
//self.placeholderLabel.hidden = self.hasText;
}
//- (void)setText:(NSString*)text{
// [super setText:text];
// [self textDidChange]; //这里调用的就是 UITextViewTextDidChangeNotification 通知的回调
//
//}
- (void)dealloc{
[[NSNotificationCenter defaultCenter]removeObserver:UITextViewTextDidChangeNotification];
}
#pragma mark - 设置属性
-(void)setPlaceholder:(NSString *)placeholder
{
_placeholder= [placeholder copy];
self.placeholderLabel.text = placeholder;
}
-(void) setPlaceholderColor:(UIColor *)placeholderColor
{
_placeholderColor = placeholderColor;
self.placeholderLabel.textColor= placeholderColor;
}
-(void) setPlaceholderFont:(UIFont *)placeholderFont
{
_placeholderFont = placeholderFont;
self.placeholderLabel.font = placeholderFont;
}
@end
@@ -0,0 +1,36 @@
//
// UMComBriefEditViewController.h
// UMCommunity
//
// Created by 张军华 on 16/5/16.
// Copyright © 2016年 Umeng. All rights reserved.
//
#import "UMComViewController.h"
@class UMComTopic;
@interface UMComBriefEditViewController : UMComViewController
/**
* 在话题界面调用,用于传入不可更改的话题
*
* @param topic 话题对象 @see UMComTopic
*
* @return UMComBriefEditViewController对象
*/
-(id)initNOModifiedTopic:(UMComTopic*)topic withPopToViewController:(UIViewController*)popToViewController;
/**
* 在其他需要先选择话题界面的时候,调用此方法来选择话题
*
* @param parentContrtoller 话题返回或者发送成功后,返回的UIViewController
*
* @return UMComBriefEditViewController对象
*/
-(id)initModifiedTopic:(UMComTopic*)topic withPopToViewController:(UIViewController*)popToViewController;
@end
@@ -0,0 +1,16 @@
//
// UMComChangeBorderBtn.h
// UMCommunity
//
// Created by 张军华 on 16/5/24.
// Copyright © 2016年 Umeng. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UMComChangeBorderBtn : UIButton
@property(nonatomic)UIColor* normalBorderColor;
@property(nonatomic)UIColor* highlightedBorderColor;
@end
@@ -0,0 +1,66 @@
//
// UMComChangeBorderBtn.m
// UMCommunity
//
// Created by 张军华 on 16/5/24.
// Copyright © 2016年 Umeng. All rights reserved.
//
#import "UMComChangeBorderBtn.h"
@implementation UMComChangeBorderBtn
- (void)touchesBegan:(NSSet<UITouch *> *)touches
withEvent:(UIEvent *)event
{
[super touchesBegan:touches withEvent:event];
if (self.highlightedBorderColor) {
[self.layer setBorderColor:self.highlightedBorderColor.CGColor];
}
}
- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(nullable UIEvent *)event
{
[super touchesEnded:touches withEvent:event];
if (self.normalBorderColor) {
[self.layer setBorderColor:self.normalBorderColor.CGColor];
}
}
- (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(nullable UIEvent *)event
{
[super touchesMoved:touches withEvent:event];
return;
//判断是否移动到控件的外面还是内部
UITouch *touch = [touches anyObject];
if (![self pointInside:[touch locationInView:self] withEvent:nil]) {
NSLog(@"touches moved outside the view");
if (self.normalBorderColor) {
[self.layer setBorderColor:self.normalBorderColor.CGColor];
}
}else {
NSLog(@"touches moved in the view");
if (self.highlightedBorderColor) {
[self.layer setBorderColor:self.highlightedBorderColor.CGColor];
}
}
}
- (void)touchesCancelled:(NSSet<UITouch *> *)touches withEvent:(nullable UIEvent *)event
{
[super touchesCancelled:touches withEvent:event];
if (self.normalBorderColor) {
[self.layer setBorderColor:self.normalBorderColor.CGColor];
}
}
@end
@@ -0,0 +1,44 @@
//
// UMComSelectTopicCell.h
// UMCommunity
//
// Created by 张军华 on 16/5/25.
// Copyright © 2016年 Umeng. All rights reserved.
//
#import <UIKit/UIKit.h>
@class UMComChangeBorderBtn;
@protocol UMComSelectTopicTableViewCellDelegate <NSObject>
@optional
/**
* 点击cell的内部的左右控件回调
*
* @param dataRowIndex 代表tableview的datasource的索引
*/
-(void) handleClickedTopicTableViewCell:(NSInteger)dataRowIndex;
@end
@interface UMComSelectTopicCell : UITableViewCell
//对应cell行
@property(nonatomic,assign)NSInteger cellRow;
//左边的话题控件
@property (nonatomic, strong) UMComChangeBorderBtn *leftLabelBtn;
//右边的话题
@property (nonatomic, strong) UMComChangeBorderBtn *rightLabelBtn;
@property (nonatomic,weak)id<UMComSelectTopicTableViewCellDelegate> selectTopicTableViewCellDelegate;
-(void)refresCellWithLeftTopicName:(NSString*)leftTopicName
withRightTopicName:(NSString*)rightTopicName
withCellRow:(NSInteger)cellRow;
@end
@@ -0,0 +1,193 @@
//
// UMComSelectTopicCell.m
// UMCommunity
//
// Created by 张军华 on 16/5/25.
// Copyright © 2016年 Umeng. All rights reserved.
//
#import "UMComSelectTopicCell.h"
#import "UMComChangeBorderBtn.h"
#import "UMComResouceDefines.h"
#import <UMComFoundation/UMComKit+Color.h>
const CGFloat g_template_selectTopic_labelWidth = 120;//cell的宽度
const CGFloat g_template_selectTopic_labeleHeight = 32;//cell的高度
const CGFloat g_template_selectTopic_labelHorizonSpace = 10;//同一行cell的间隔
const CGFloat g_template_selectTopic_labelVerticalSpace = 10;//同一列cell的间隔
@interface UMComSelectTopicCell ()
@end
@implementation UMComSelectTopicCell
-(void)handleClickTopicCollectionCell:(UIButton*)target
{
NSInteger dataRowIndex = target.tag;
if(self.selectTopicTableViewCellDelegate &&
[self.selectTopicTableViewCellDelegate respondsToSelector:@selector(handleClickedTopicTableViewCell:)]){
[self.selectTopicTableViewCellDelegate handleClickedTopicTableViewCell:dataRowIndex];
}
}
-(instancetype)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if (self) {
UIColor* normalColor = UMComColorWithHexString(@"#999999");
UIColor* highlightedColor = UMComColorWithHexString(@"#469ef8");
self.leftLabelBtn = [UMComChangeBorderBtn buttonWithType:UIButtonTypeCustom];
self.leftLabelBtn.frame = self.bounds;
[self.leftLabelBtn.layer setCornerRadius:6];
[self.leftLabelBtn.layer setBorderWidth:1];
self.leftLabelBtn.tag = -1;
self.leftLabelBtn.normalBorderColor = normalColor;
self.leftLabelBtn.highlightedBorderColor = highlightedColor;
[self.leftLabelBtn setTitleColor:normalColor forState:UIControlStateNormal];
[self.leftLabelBtn setTitleColor:highlightedColor forState:UIControlStateHighlighted];
self.leftLabelBtn.backgroundColor = [UIColor clearColor];
[self.leftLabelBtn.layer setBorderColor:normalColor.CGColor];
[self.contentView addSubview:self.leftLabelBtn];
[self.leftLabelBtn addTarget:self action:@selector(handleClickTopicCollectionCell:) forControlEvents:UIControlEventTouchUpInside];
[self.contentView addSubview:self.leftLabelBtn];
self.leftLabelBtn.titleLabel.lineBreakMode = NSLineBreakByTruncatingTail;
self.rightLabelBtn = [UMComChangeBorderBtn buttonWithType:UIButtonTypeCustom];
self.rightLabelBtn.frame = self.bounds;
[self.rightLabelBtn.layer setCornerRadius:6];
[self.rightLabelBtn.layer setBorderWidth:1];
self.rightLabelBtn.normalBorderColor = normalColor;
self.rightLabelBtn.highlightedBorderColor = highlightedColor;
[self.rightLabelBtn setTitleColor:normalColor forState:UIControlStateNormal];
[self.rightLabelBtn setTitleColor:highlightedColor forState:UIControlStateHighlighted];
self.rightLabelBtn.backgroundColor = [UIColor clearColor];
[self.rightLabelBtn.layer setBorderColor:normalColor.CGColor];
[self.contentView addSubview:self.rightLabelBtn];
self.rightLabelBtn.tag = -1;
[self.contentView addSubview:self.rightLabelBtn];
self.rightLabelBtn.titleLabel.lineBreakMode = NSLineBreakByTruncatingTail;
CGFloat cellWidth = [UIScreen mainScreen].bounds.size.width;
CGFloat halfWidth = cellWidth/2;
CGFloat leftX = halfWidth - g_template_selectTopic_labelHorizonSpace/2 - g_template_selectTopic_labelWidth;
self.leftLabelBtn.frame = CGRectMake(leftX, 0, g_template_selectTopic_labelWidth, g_template_selectTopic_labeleHeight);
CGFloat rightX = halfWidth - g_template_selectTopic_labelHorizonSpace/2;
self.rightLabelBtn.frame = CGRectMake(rightX, 0, g_template_selectTopic_labelWidth, g_template_selectTopic_labeleHeight);
self.selectionStyle = UITableViewCellSelectionStyleNone;
self.selectedBackgroundView.backgroundColor = [UIColor clearColor];
}
return self;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(nullable NSString *)reuseIdentifier
{
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
UIColor* normalColor = UMComColorWithHexString(@"#999999");
UIColor* highlightedColor = UMComColorWithHexString(@"#469ef8");
self.leftLabelBtn = [UMComChangeBorderBtn buttonWithType:UIButtonTypeCustom];
self.leftLabelBtn.frame = self.bounds;
[self.leftLabelBtn.layer setCornerRadius:6];
[self.leftLabelBtn.layer setBorderWidth:1];
self.leftLabelBtn.tag = -1;
self.leftLabelBtn.normalBorderColor = normalColor;
self.leftLabelBtn.highlightedBorderColor = highlightedColor;
[self.leftLabelBtn setTitleColor:normalColor forState:UIControlStateNormal];
[self.leftLabelBtn setTitleColor:highlightedColor forState:UIControlStateHighlighted];
self.leftLabelBtn.backgroundColor = [UIColor clearColor];
[self.leftLabelBtn.layer setBorderColor:normalColor.CGColor];
[self.contentView addSubview:self.leftLabelBtn];
[self.leftLabelBtn addTarget:self action:@selector(handleClickTopicCollectionCell:) forControlEvents:UIControlEventTouchUpInside];
self.leftLabelBtn.titleLabel.lineBreakMode = NSLineBreakByTruncatingTail;
[self.contentView addSubview:self.leftLabelBtn];
self.rightLabelBtn = [UMComChangeBorderBtn buttonWithType:UIButtonTypeCustom];
self.rightLabelBtn.frame = self.bounds;
[self.rightLabelBtn.layer setCornerRadius:6];
[self.rightLabelBtn.layer setBorderWidth:1];
self.rightLabelBtn.normalBorderColor = normalColor;
self.rightLabelBtn.highlightedBorderColor = highlightedColor;
[self.rightLabelBtn setTitleColor:normalColor forState:UIControlStateNormal];
[self.rightLabelBtn setTitleColor:highlightedColor forState:UIControlStateHighlighted];
self.rightLabelBtn.backgroundColor = [UIColor clearColor];
[self.rightLabelBtn.layer setBorderColor:normalColor.CGColor];
[self.contentView addSubview:self.rightLabelBtn];
self.rightLabelBtn.tag = -1;
[self.rightLabelBtn addTarget:self action:@selector(handleClickTopicCollectionCell:) forControlEvents:UIControlEventTouchUpInside];
self.rightLabelBtn.titleLabel.lineBreakMode = NSLineBreakByTruncatingTail;
[self.contentView addSubview:self.rightLabelBtn];
CGFloat cellWidth = [UIScreen mainScreen].bounds.size.width;
CGFloat halfWidth = cellWidth/2;
CGFloat leftX = halfWidth - g_template_selectTopic_labelHorizonSpace/2 - g_template_selectTopic_labelWidth;
self.leftLabelBtn.frame = CGRectMake(leftX, 0, g_template_selectTopic_labelWidth, g_template_selectTopic_labeleHeight);
CGFloat rightX = halfWidth + g_template_selectTopic_labelHorizonSpace/2;
self.rightLabelBtn.frame = CGRectMake(rightX, 0, g_template_selectTopic_labelWidth, g_template_selectTopic_labeleHeight);
}
return self;
}
-(void)refresCellWithLeftTopicName:(NSString*)leftTopicName
withRightTopicName:(NSString*)rightTopicName
withCellRow:(NSInteger)cellRow
{
self.cellRow = cellRow;
if (leftTopicName) {
self.leftLabelBtn.hidden = NO;
self.leftLabelBtn.tag = cellRow*2;
[self.leftLabelBtn setTitle:leftTopicName forState:UIControlStateNormal];
}
else
{
self.leftLabelBtn.tag = -1;
self.leftLabelBtn.hidden = YES;
}
if (rightTopicName) {
self.rightLabelBtn.hidden = NO;
self.rightLabelBtn.tag = cellRow*2 + 1;
[self.rightLabelBtn setTitle:rightTopicName forState:UIControlStateNormal];
}
else
{
self.rightLabelBtn.tag = -1;
self.rightLabelBtn.hidden = YES;
}
}
@end
@@ -0,0 +1,35 @@
//
// UMComSelectTopicViewController.h
// UMCommunity
//
// Created by 张军华 on 16/5/18.
// Copyright © 2016年 Umeng. All rights reserved.
//
#import "UMComViewController.h"
#import "UMComRequestTableViewController.h"
@class UMComTopic;
typedef void (^SelectTopicViewFinishAction)(UMComTopic* topic);
typedef void (^CloseTopicViewAction)();
//typedef NS_ENUM(NSInteger, UMComSelectTopictType)
//{
// UMComSelectTopic_FromViewControllerWithoutTopic, //从其他viewcontrller 没有代入UMComTopic
// UMComSelectTopic_FromViewControllerWithTopic, //从其他viewcontrller 代入UMComTopic(目前类型不处理)
// UMComSelectTopic_FromEditViewController, //从编辑界面
//};
@interface UMComSelectTopicViewController : UMComRequestTableViewController
//@property(nonatomic,assign)UMComSelectTopictType selectTopictType;
//@property(nonatomic,strong)UMComTopic* curTopic;
@property(nonatomic,copy)CloseTopicViewAction closeTopicViewAction;
@property(nonatomic,copy)SelectTopicViewFinishAction selectTopicViewFinishAction;
@end
@@ -0,0 +1,267 @@
//
// UMComSelectTopicViewController.m
// UMCommunity
//
// Created by 张军华 on 16/5/18.
// Copyright © 2016年 Umeng. All rights reserved.
//
#import "UMComSelectTopicViewController.h"
#import "UMComTopicListDataController.h"
#import "UMComResouceDefines.h"
#import <UIKit/UIKit.h>
#import <UMComDataStorage/UMComTopic.h>
#import "UMComChangeBorderBtn.h"
#import "UMComShowToast.h"
#import "UMComiToast.h"
#import "UMComSelectTopicCell.h"
#import <UMComFoundation/UMComKit+Color.h>
const CGFloat g_template_selectTopic_closeViewHeight = 60.f;//关闭view的高度
const CGFloat g_template_selectTopic_closeBTNHeight = 44.f;//关闭按钮的高度
const CGFloat g_template_selectTopic_closeBTNWidth = 44.f;//关闭按钮的高度
const CGFloat g_template_selectTopic_cellWidth = 120;//cell的宽度
const CGFloat g_template_selectTopic_cellHeight = 32;//cell的高度
const CGFloat g_template_selectTopic_horizonSpace = 10;//同一行cell的间隔
const CGFloat g_template_selectTopic_verticalSpace = 10;//同一列cell的间隔
NSString* const UMComSelectTopicCollectionCellIdentifier = @"UMComSelectTopicCollectionCellIdentifier";
@interface UMComSelectTopicViewController ()<UITableViewDataSource,UITableViewDelegate,UMComSelectTopicTableViewCellDelegate>
@property(nonatomic)UMComTopicsAllDataController* topicsAllDataController;
@property(nonatomic,readwrite,strong)UIView* closeView;
@property(nonatomic,readwrite,strong)UIButton* closeBtn;
@property (weak, nonatomic) IBOutlet UIImageView *imgHeader;
@property (weak, nonatomic) IBOutlet UILabel *laberheader1;
@property (weak, nonatomic) IBOutlet UILabel *labelheader2;
@property (weak, nonatomic) IBOutlet UIView *headerView;
//@property (weak, nonatomic) IBOutlet UITableView *tableView;
-(void) initHeaderView;
-(void) createCloseViewIfNoExist;
-(void) handleCloseBtn:(id)target;
-(void) createTableView;
@end
@implementation UMComSelectTopicViewController
-(void) initHeaderView
{
self.imgHeader.image = UMComSimpleImageWithImageName(@"um_com_cheers");
self.imgHeader.backgroundColor = [UIColor clearColor];
self.laberheader1.text = @"为内容选个贴切的版块";
self.labelheader2.text = @"会找到志同道和的人哦";
self.laberheader1.font = UMComFontNotoSansLightWithSafeSize(14);
self.laberheader1.textColor = UMComColorWithHexString(@"#FFFFFF");
self.labelheader2.font = UMComFontNotoSansLightWithSafeSize(14);
self.labelheader2.textColor = UMComColorWithHexString(@"#FFFFFF");
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
[self.navigationController setNavigationBarHidden:YES];
[self initHeaderView];
[self createTableView];
self.topicsAllDataController = [[UMComTopicsAllDataController alloc] initWithRequestType:UMComRequestType_AllTopic count:30];;
self.dataController = self.topicsAllDataController;
__weak typeof(self) weakself = self;
[self.dataController refreshNewDataCompletion:^(NSArray *responseData, NSError *error) {
if (error) {
[UMComShowToast showFetchResultTipWithError:error];
}
[weakself.tableView reloadData];
}];
}
- (void)updateTableviewConstraints
{
UITableView *tableView = self.tableView;
UIView* headerView = self.headerView;
[tableView setTranslatesAutoresizingMaskIntoConstraints:NO];
NSDictionary *dict1 = NSDictionaryOfVariableBindings(tableView,headerView);
NSDictionary *metrics = @{@"hPadding":@0,@"vPadding":@(10)};
NSString *vfl = @"|-hPadding-[tableView]-hPadding-|";
NSString *vfl0 = @"V:|-0-[headerView]-vPadding-[tableView]-0-|";
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:vfl options:0 metrics:metrics views:dict1]];
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:vfl0 options:0 metrics:metrics views:dict1]];
}
-(void) viewDidAppear:(BOOL)animated
{
[self createCloseViewIfNoExist];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(void) dealloc
{
//NSLog(@"UMComSelectTopicViewController_dealloc");
}
-(void) createCloseViewIfNoExist
{
if (!self.closeView) {
self.closeView = [[UIView alloc] initWithFrame:CGRectMake(0, self.view.bounds.size.height - g_template_selectTopic_closeViewHeight, self.view.bounds.size.width, g_template_selectTopic_closeViewHeight)];
self.closeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
self.closeBtn.frame = CGRectMake(0,0,g_template_selectTopic_closeBTNWidth,g_template_selectTopic_closeBTNHeight);
self.closeBtn.center = CGPointMake(self.closeView.bounds.size.width/2, self.closeView.bounds.size.height/2);
[self.closeView addSubview:self.closeBtn];
[self.closeBtn setImage:UMComSimpleImageWithImageName(@"um_com_close") forState:UIControlStateNormal];
[self.closeBtn setImage:UMComSimpleImageWithImageName(@"um_com_close_click") forState:UIControlStateHighlighted];
self.closeView.backgroundColor = UMComColorWithHexString(@"#e8eaee");
self.closeView.alpha = 0.8;
[self.view addSubview:self.closeView];
[self.closeBtn addTarget:self action:@selector(handleCloseBtn:) forControlEvents:UIControlEventTouchUpInside];
}
}
-(void) handleCloseBtn:(id)target
{
[self.navigationController setNavigationBarHidden:NO];
if (self.closeTopicViewAction) {
self.closeTopicViewAction();
}
else{
[self.navigationController popViewControllerAnimated:YES];
}
}
-(void) createTableView
{
//设置tableview
[self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
[self.tableView setSeparatorColor:[UIColor clearColor]];
[self.tableView setAllowsSelection:NO];
self.tableView.dataSource = self;
self.tableView.delegate = self;
// //设置上来加载控件的frame
// CGRect loadMoreStatusViewRC = self.loadMoreStatusView.frame;
// CGFloat cellWidth = [UIScreen mainScreen].bounds.size.width;
// loadMoreStatusViewRC.origin.x = cellWidth/2 - g_template_selectTopic_cellWidth - g_template_selectTopic_horizonSpace - g_template_selectTopic_horizonSpace;
//
// loadMoreStatusViewRC.size.width = g_template_selectTopic_cellWidth*2 + g_template_selectTopic_horizonSpace;
// self.loadMoreStatusView.frame = loadMoreStatusViewRC;
}
#pragma mark - UMComSelectTopicCollectionCellDelegate
-(void)layouttableViewCell:(UMComSelectTopicCell*)cell indexPath:(NSIndexPath *)indexPath
{
NSInteger cellRow = indexPath.row;
NSInteger rowCount = (self.topicsAllDataController.dataArray.count + 1)/2;
if (cellRow >= rowCount) {
return;
}
NSInteger leftDataIndex = cellRow*2;
NSInteger rightDataIndex = cellRow*2 + 1;
NSString* leftTopicName = nil;
if (leftDataIndex >=0 && leftDataIndex < self.topicsAllDataController.dataArray.count) {
UMComTopic* leftTopic = self.topicsAllDataController.dataArray[leftDataIndex];
if (leftTopic && [leftTopic isKindOfClass:[UMComTopic class]]) {
leftTopicName = leftTopic.name;
}
}
NSString* rightTopicName = nil;
if (rightDataIndex > 0 && rightDataIndex < self.topicsAllDataController.dataArray.count) {
UMComTopic* rightTopic = self.topicsAllDataController.dataArray[rightDataIndex];
if (rightTopic && [rightTopic isKindOfClass:[UMComTopic class]]) {
rightTopicName = rightTopic.name;
}
}
[cell refresCellWithLeftTopicName:leftTopicName withRightTopicName:rightTopicName withCellRow:cellRow];
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return g_template_selectTopic_cellHeight + g_template_selectTopic_horizonSpace;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return (self.topicsAllDataController.dataArray.count + 1)/2;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *kUMComSelectTopicTableViewCellIdentifier = @"kUMComSelectTopicTableViewCellIdentifier";
UMComSelectTopicCell* cell = [tableView dequeueReusableCellWithIdentifier:kUMComSelectTopicTableViewCellIdentifier];
if (!cell) {
cell = [[UMComSelectTopicCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:kUMComSelectTopicTableViewCellIdentifier];
}
cell.selectTopicTableViewCellDelegate = self;
[self layouttableViewCell:cell indexPath:indexPath];
return cell;
}
#pragma mark - UMComSelectTopicTableViewCellDelegate
-(void) handleClickedTopicTableViewCell:(NSInteger)dataRowIndex
{
if (dataRowIndex < 0) {
return;
}
if (dataRowIndex < self.topicsAllDataController.dataArray.count) {
UMComTopic* topic = self.topicsAllDataController.dataArray[dataRowIndex];
if (topic && [topic isKindOfClass:[UMComTopic class]]) {
//NSLog(@"handleClickTopicCollectionCell:name = %@. index = %@",topic.name,indexPath);
[self.navigationController setNavigationBarHidden:NO];
if (self.selectTopicViewFinishAction) {
self.selectTopicViewFinishAction(topic);
}
}
}
}
@end
@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9532" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9530"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="UMComSelectTopicViewController">
<connections>
<outlet property="headerView" destination="IZB-ih-9tz" id="hOu-UI-enE"/>
<outlet property="imgHeader" destination="aIk-0C-8eS" id="HGD-Rp-oss"/>
<outlet property="labelheader2" destination="QPt-e2-Udb" id="QEs-vs-Bgz"/>
<outlet property="laberheader1" destination="MBy-JW-dDT" id="p9d-2H-OOp"/>
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="IZB-ih-9tz">
<rect key="frame" x="0.0" y="0.0" width="320" height="100"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="MBy-JW-dDT">
<rect key="frame" x="130" y="39" width="190" height="21"/>
<constraints>
<constraint firstAttribute="height" constant="21" id="Vld-fV-Jop"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="aIk-0C-8eS">
<rect key="frame" x="75" y="40" width="40" height="40"/>
<constraints>
<constraint firstAttribute="height" constant="40" id="h46-6o-2Um"/>
<constraint firstAttribute="width" constant="40" id="vN3-2q-Wzc"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="QPt-e2-Udb">
<rect key="frame" x="130" y="65" width="190" height="20.5"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="QPt-e2-Udb" secondAttribute="trailing" id="3yv-9G-Ksj"/>
<constraint firstItem="QPt-e2-Udb" firstAttribute="top" secondItem="MBy-JW-dDT" secondAttribute="bottom" constant="5" id="4A7-1O-JeL"/>
<constraint firstItem="MBy-JW-dDT" firstAttribute="leading" secondItem="aIk-0C-8eS" secondAttribute="trailing" constant="15" id="Afc-wr-Lys"/>
<constraint firstAttribute="height" constant="100" id="cxS-9W-w0e"/>
<constraint firstItem="MBy-JW-dDT" firstAttribute="top" secondItem="IZB-ih-9tz" secondAttribute="top" constant="39" id="jYO-FH-WvG"/>
<constraint firstAttribute="trailing" secondItem="MBy-JW-dDT" secondAttribute="trailing" id="jm5-T9-lDu"/>
<constraint firstItem="aIk-0C-8eS" firstAttribute="leading" secondItem="IZB-ih-9tz" secondAttribute="leading" constant="75" id="rBh-si-vFB"/>
<constraint firstItem="aIk-0C-8eS" firstAttribute="top" secondItem="IZB-ih-9tz" secondAttribute="top" constant="40" id="rHu-GX-BCh"/>
<constraint firstItem="QPt-e2-Udb" firstAttribute="leading" secondItem="aIk-0C-8eS" secondAttribute="trailing" constant="15" id="uzO-ja-eZz"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="IZB-ih-9tz" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" id="aeT-KE-Elf"/>
<constraint firstItem="IZB-ih-9tz" firstAttribute="top" secondItem="i5M-Pr-FkT" secondAttribute="top" id="dpv-BA-FRk"/>
<constraint firstAttribute="trailing" secondItem="IZB-ih-9tz" secondAttribute="trailing" id="qdc-RO-hNP"/>
</constraints>
<point key="canvasLocation" x="-145" y="163"/>
</view>
</objects>
</document>