//实现方法,方法内调用的方法具体见文件中的“导航条方法类”

- (void)addTabViewOnWindow

{

    MNZTopTabViews *tabViews = [MNZTopTabViews sharedTabViews];

    float height = MAIN_SCREEN_HEIGHT;

    [tabViews setFrame:CGRectMake(0, height-51, MAIN_SCREEN_WIDTH, 51)];

    [[MNZAppDelegate getAppDelegate].window addSubview:tabViews];

}

//调用

[self addTabViewOnWindow];

 

 

//在类中先声明

@interface MNZCommodityDetailViewController ()<UITableViewDataSource,UITableViewDelegate,UIScrollViewDelegate>

{

    UIView *topTabViews;

}

 

@end

//当前页面不需要出现时用到 

- (void)viewWillAppear:(BOOL)animated

{

    [super viewWillAppear:animated];

    self.navigationItem.hidesBackButton = NO;

    self.titleStr = nil;

    

    if (topTabViews == nil) {

        NSArray *ss = [UIApplication sharedApplication].keyWindow.subviews;

        for (UIView * view in ss) {

            if ([view.class.description isEqualToString:@"MNZTopTabViews"]) {

                topTabViews =(MNZTopTabViews *)view;

                break;

            }

        }

    }

    topTabViews.hidden = YES;

    

    [self layoutSubFrame];

    

    if (lastProuctDetail != nil && [lastProuctDetail.commentCount isEqualToString:_productDetail.commentCount] == NO ) {

        [self getCommentFromServer];

        

        [[NSNotificationCenter defaultCenter] postNotificationName:kUpdateData object:nil userInfo:@{kUPdateDataObject:_productDetail}];

    }

    

    lastProuctDetail = _productDetail.copy;

}

 

//下一个页面需要出现时用到 

-(void)viewWillDisappear:(BOOL)animated{

    [super viewWillDisappear:animated];

    

    if (topTabViews == nil) {

       NSArray *ss = [UIApplication sharedApplication].keyWindow.subviews;

        for (UIView * view in ss) {

            if ([view.class.description isEqualToString:@"MNZTopTabViews"]) {

                topTabViews =(MNZTopTabViews *)view;

                break;

            }

        }

    }

   

    topTabViews.hidden = NO;

    

    if (self.productInfo != nil) {

        self.productInfo.id = _productDetail.id;

        self.productInfo.productName = _productDetail.productName;

        self.productInfo.status = _productDetail.status;

        self.productInfo.price = _productDetail.price;

        self.productInfo.likeCount = _productDetail.likeCount;

        self.productInfo.liked = _productDetail.liked;

        self.productInfo.commented = _productDetail.commented;

        self.productInfo.commentCount = _productDetail.commentCount;

    }

}

 

红色字体为关键代码