Skip to content

Commit

Permalink
详情页和评论页添加注释
Browse files Browse the repository at this point in the history
  • Loading branch information
dsxNiubility committed Feb 19, 2015
1 parent 82e698f commit 9e7d699
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 22 deletions.
7 changes: 6 additions & 1 deletion 81 - 网易新闻/Detail/SXDetailController.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ @interface SXDetailController ()<UIWebViewDelegate>
@end

@implementation SXDetailController
#pragma mark - ******************** 返回按钮
- (IBAction)backBtn:(id)sender {
[self.navigationController popViewControllerAnimated:YES];
[self.navigationController setNavigationBarHidden:NO animated:YES];
}

#pragma mark - ******************** 首次加载
- (void)viewDidLoad {
[super viewDidLoad];
self.webView.delegate = self;
Expand All @@ -40,12 +42,12 @@ - (void)viewDidLoad {

self.automaticallyAdjustsScrollViewInsets = NO;
}

- (void)viewWillAppear:(BOOL)animated
{
[self.navigationController setNavigationBarHidden:YES animated:YES];
}

#pragma mark - ******************** 拼接html语言
- (void)showInWebView
{
NSMutableString *html = [NSMutableString string];
Expand Down Expand Up @@ -99,6 +101,7 @@ - (NSString *)touchBody
return body;
}

#pragma mark - ******************** 将发出通知时调用
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
NSString *url = request.URL.absoluteString;
Expand All @@ -112,6 +115,7 @@ - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)
return YES;
}

#pragma mark - ******************** 保存到相册方法
- (void)savePictureToAlbum:(NSString *)src
{
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"确定要保存到相册吗?" preferredStyle:UIAlertControllerStyleActionSheet];
Expand All @@ -131,6 +135,7 @@ - (void)savePictureToAlbum:(NSString *)src
[self presentViewController:alert animated:YES completion:nil];
}

#pragma mark - ******************** 即将跳转时
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
[[NSNotificationCenter defaultCenter]postNotification:[NSNotification notificationWithName:@"contentStart" object:nil]];
Expand Down
1 change: 1 addition & 0 deletions 81 - 网易新闻/Detail/SXDetailImgModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

@implementation SXDetailImgModel

/** 便利构造器方法 */
+ (instancetype)detailImgWithDict:(NSDictionary *)dict
{
SXDetailImgModel *imgModel = [[self alloc]init];
Expand Down
1 change: 1 addition & 0 deletions 81 - 网易新闻/Detail/SXDetailModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#import "SXDetailImgModel.h"
@implementation SXDetailModel

/** 便利构造器 */
+ (instancetype)detailWithDict:(NSDictionary *)dict
{
SXDetailModel *detail = [[self alloc]init];
Expand Down
1 change: 1 addition & 0 deletions 81 - 网易新闻/Detail/SXReplyCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
@interface SXReplyCell : UITableViewCell

@property(nonatomic,strong) SXReplyModel *replyModel;
/** 用户的发言 */
@property (weak, nonatomic) IBOutlet UILabel *sayLabel;
@end
12 changes: 5 additions & 7 deletions 81 - 网易新闻/Detail/SXReplyCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,20 @@
#import "SXReplyCell.h"

@interface SXReplyCell ()

/** 用户名称 */
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
/** 用户ip信息 */
@property (weak, nonatomic) IBOutlet UILabel *addressLabel;

/** 用户的点赞数 */
@property (weak, nonatomic) IBOutlet UILabel *supposeLabel;
@property (nonatomic,assign) CGFloat maxY;


@end

@implementation SXReplyCell


/** set方法数据分发 */
- (void)setReplyModel:(SXReplyModel *)replyModel
{
_replyModel = replyModel;
Expand All @@ -31,8 +33,4 @@ - (void)setReplyModel:(SXReplyModel *)replyModel
}


- (void)awakeFromNib {

}

@end
3 changes: 2 additions & 1 deletion 81 - 网易新闻/Detail/SXReplyHeader.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@

@implementation SXReplyHeader


/** 类方法快速返回热门跟帖的view */
+ (instancetype)replyViewFirst
{
NSArray *array = [[NSBundle mainBundle] loadNibNamed:@"SXReplyHeader" owner:nil options:nil];
return [array firstObject];
}

/** 类方法快速返回最新跟帖的view */
+ (instancetype)replyViewLast
{
NSArray *array = [[NSBundle mainBundle] loadNibNamed:@"SXReplyHeader" owner:nil options:nil];
Expand Down
4 changes: 4 additions & 0 deletions 81 - 网易新闻/Detail/SXReplyModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@

@interface SXReplyModel : NSObject

/** 用户的姓名 */
@property(nonatomic,copy) NSString *name;
/** 用户的ip信息 */
@property(nonatomic,copy) NSString *address;
/** 用户的发言 */
@property(nonatomic,copy) NSString *say;
/** 用户的点赞 */
@property(nonatomic,copy) NSString *suppose;

@end
19 changes: 6 additions & 13 deletions 81 - 网易新闻/Detail/SXReplyViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,12 @@ @interface SXReplyViewController ()<UITableViewDataSource,UITableViewDelegate>
@implementation SXReplyViewController
static NSString *ID = @"replyCell";


#pragma mark - ******************** 返回按钮
- (IBAction)back:(id)sender {
[self.navigationController popViewControllerAnimated:YES];
}

- (void)viewDidLoad {
[super viewDidLoad];

// self.tableView.contentOffset = CGPointMake(0, 50);
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
}

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

#pragma mark - ******************** tbv数据源方法
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 2;
Expand All @@ -61,6 +50,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
cell.replyModel = model;
return cell;
}
/** 返回一个view来当tbv的header */
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
if (section == 0) {
Expand All @@ -70,6 +60,7 @@ - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger
}
}

/** 通过提前计算来返回行高 */
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
SXReplyCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
Expand All @@ -83,6 +74,8 @@ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPa

return cell.sayLabel.frame.origin.y + size.height + 10;
}

/** 预估行高,这个方法可以减少上面方法的调用次数,提高性能 */
- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath {

return 130;
Expand Down

0 comments on commit 9e7d699

Please sign in to comment.