iOS tableViewCell 代理

来源:互联网 发布:机顶盒刷linux 编辑:程序博客网 时间:2024/06/05 01:07


#import <UIKit/UIKit.h>

#import "CompeteListModel.h"

@protocol RankDelegate <NSObject>

-(void)rankClick:(NSString*)number;

@end

@interface CompeteTableViewCell :UITableViewCell

@property (nonatomic,strong)CompeteModel *model;

@property (nonatomic,weak)id<RankDelegate> delegate;

@property (weak,nonatomic) IBOutletUIView *upYellow;

@property (weak,nonatomic) IBOutletUIView *downYellow;

@end


- (IBAction)rank:(id)sender {

    if ([self.delegaterespondsToSelector:@selector(rankClick:)]) {

        [self.delegaterankClick:self.model.tnno];

        NSLog(@"代理%@",self.model.tnno);

    }

    

}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{

    

        staticNSString *ID =@"CompeteTableViewCell";

    CompeteTableViewCell *cell = [tableViewdequeueReusableCellWithIdentifier:ID];

    if (cell==nil) {

        cell =[[[UINibnibWithNibName:ID bundle:nil]instantiateWithOwner:selfoptions:nil]objectAtIndex:0];

        cell.selectionStyle =UITableViewCellSelectionStyleNone

        

    }

    if (self.type) {

        cell.upYellow.backgroundColor=[UIColoryellowColor];

        cell.downYellow.backgroundColor=[UIColoryellowColor];

    }else

    {

        cell.upYellow.backgroundColor=kColor(0,143, 226);

        cell.downYellow.backgroundColor=kColor(0,143, 226);

    }


//   cell.model=_competeModel1.tournamentList[indexPath.row];

    cell.model=_arrayList[indexPath.row];

    

    cell.delegate=self;

    return cell;

}



-(void)rankClick:(NSString *)number

{

    NSLog(@"点击了代理%@",number);

    competeRankTableController *comRankVC=[[competeRankTableControlleralloc] init];

    

  

    comRankVC.model=number;

    

    

    NSDictionary *dict = [[NSDictionaryalloc]initWithObjectsAndKeys:comRankVC,@"Hidden",nil];

    NSNotification *notification = [NSNotificationnotificationWithName:@"tongzhiHidden"object:niluserInfo:dict];

    [[NSNotificationCenterdefaultCenter]postNotification:notification];

    [self.tabBarController.viewsetFrame:CGRectMake(0,0, IPHONE_WIDTH,IPHONE_HEIGHT + 60)];

    

    

    [self.navigationControllerpushViewController:comRankVCanimated:YES];

    

}



0 0
原创粉丝点击