From 9e7d699bf7d9853718318e012cb39c8e64f7fa0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=91=A3=E9=93=82=E7=84=B6?= Date: Thu, 19 Feb 2015 18:51:41 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=A6=E6=83=85=E9=A1=B5=E5=92=8C=E8=AF=84?= =?UTF-8?q?=E8=AE=BA=E9=A1=B5=E6=B7=BB=E5=8A=A0=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Detail/SXDetailController.m" | 7 ++++++- .../Detail/SXDetailImgModel.m" | 1 + .../Detail/SXDetailModel.m" | 1 + .../Detail/SXReplyCell.h" | 1 + .../Detail/SXReplyCell.m" | 12 +++++------- .../Detail/SXReplyHeader.m" | 3 ++- .../Detail/SXReplyModel.h" | 4 ++++ .../Detail/SXReplyViewController.m" | 19 ++++++------------- 8 files changed, 26 insertions(+), 22 deletions(-) diff --git "a/81 - \347\275\221\346\230\223\346\226\260\351\227\273/Detail/SXDetailController.m" "b/81 - \347\275\221\346\230\223\346\226\260\351\227\273/Detail/SXDetailController.m" index db549ac..a697400 100644 --- "a/81 - \347\275\221\346\230\223\346\226\260\351\227\273/Detail/SXDetailController.m" +++ "b/81 - \347\275\221\346\230\223\346\226\260\351\227\273/Detail/SXDetailController.m" @@ -21,11 +21,13 @@ @interface SXDetailController () @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; @@ -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]; @@ -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; @@ -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]; @@ -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]]; diff --git "a/81 - \347\275\221\346\230\223\346\226\260\351\227\273/Detail/SXDetailImgModel.m" "b/81 - \347\275\221\346\230\223\346\226\260\351\227\273/Detail/SXDetailImgModel.m" index d375ea3..36b8581 100644 --- "a/81 - \347\275\221\346\230\223\346\226\260\351\227\273/Detail/SXDetailImgModel.m" +++ "b/81 - \347\275\221\346\230\223\346\226\260\351\227\273/Detail/SXDetailImgModel.m" @@ -10,6 +10,7 @@ @implementation SXDetailImgModel +/** 便利构造器方法 */ + (instancetype)detailImgWithDict:(NSDictionary *)dict { SXDetailImgModel *imgModel = [[self alloc]init]; diff --git "a/81 - \347\275\221\346\230\223\346\226\260\351\227\273/Detail/SXDetailModel.m" "b/81 - \347\275\221\346\230\223\346\226\260\351\227\273/Detail/SXDetailModel.m" index ffa96d4..58e0eb6 100644 --- "a/81 - \347\275\221\346\230\223\346\226\260\351\227\273/Detail/SXDetailModel.m" +++ "b/81 - \347\275\221\346\230\223\346\226\260\351\227\273/Detail/SXDetailModel.m" @@ -10,6 +10,7 @@ #import "SXDetailImgModel.h" @implementation SXDetailModel +/** 便利构造器 */ + (instancetype)detailWithDict:(NSDictionary *)dict { SXDetailModel *detail = [[self alloc]init]; diff --git "a/81 - \347\275\221\346\230\223\346\226\260\351\227\273/Detail/SXReplyCell.h" "b/81 - \347\275\221\346\230\223\346\226\260\351\227\273/Detail/SXReplyCell.h" index 9fb196c..428816c 100644 --- "a/81 - \347\275\221\346\230\223\346\226\260\351\227\273/Detail/SXReplyCell.h" +++ "b/81 - \347\275\221\346\230\223\346\226\260\351\227\273/Detail/SXReplyCell.h" @@ -12,5 +12,6 @@ @interface SXReplyCell : UITableViewCell @property(nonatomic,strong) SXReplyModel *replyModel; +/** 用户的发言 */ @property (weak, nonatomic) IBOutlet UILabel *sayLabel; @end diff --git "a/81 - \347\275\221\346\230\223\346\226\260\351\227\273/Detail/SXReplyCell.m" "b/81 - \347\275\221\346\230\223\346\226\260\351\227\273/Detail/SXReplyCell.m" index 277b95a..f256d70 100644 --- "a/81 - \347\275\221\346\230\223\346\226\260\351\227\273/Detail/SXReplyCell.m" +++ "b/81 - \347\275\221\346\230\223\346\226\260\351\227\273/Detail/SXReplyCell.m" @@ -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; @@ -31,8 +33,4 @@ - (void)setReplyModel:(SXReplyModel *)replyModel } -- (void)awakeFromNib { - -} - @end diff --git "a/81 - \347\275\221\346\230\223\346\226\260\351\227\273/Detail/SXReplyHeader.m" "b/81 - \347\275\221\346\230\223\346\226\260\351\227\273/Detail/SXReplyHeader.m" index ea0586b..52dadc8 100644 --- "a/81 - \347\275\221\346\230\223\346\226\260\351\227\273/Detail/SXReplyHeader.m" +++ "b/81 - \347\275\221\346\230\223\346\226\260\351\227\273/Detail/SXReplyHeader.m" @@ -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]; diff --git "a/81 - \347\275\221\346\230\223\346\226\260\351\227\273/Detail/SXReplyModel.h" "b/81 - \347\275\221\346\230\223\346\226\260\351\227\273/Detail/SXReplyModel.h" index 6c301ab..801b687 100644 --- "a/81 - \347\275\221\346\230\223\346\226\260\351\227\273/Detail/SXReplyModel.h" +++ "b/81 - \347\275\221\346\230\223\346\226\260\351\227\273/Detail/SXReplyModel.h" @@ -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 diff --git "a/81 - \347\275\221\346\230\223\346\226\260\351\227\273/Detail/SXReplyViewController.m" "b/81 - \347\275\221\346\230\223\346\226\260\351\227\273/Detail/SXReplyViewController.m" index 6f52efa..d3a0d53 100644 --- "a/81 - \347\275\221\346\230\223\346\226\260\351\227\273/Detail/SXReplyViewController.m" +++ "b/81 - \347\275\221\346\230\223\346\226\260\351\227\273/Detail/SXReplyViewController.m" @@ -20,23 +20,12 @@ @interface SXReplyViewController () @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; @@ -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) { @@ -70,6 +60,7 @@ - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger } } +/** 通过提前计算来返回行高 */ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { SXReplyCell *cell = [tableView dequeueReusableCellWithIdentifier:ID]; @@ -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;