• loadNibNamed 的使用


    感觉很怪怪的

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

    {

        static NSString *CellIdentifier = @"ApplicationCell";

        ApplicationCell *cell = (ApplicationCell *)[tableViewdequeueReusableCellWithIdentifier:CellIdentifier];

        if (cell == nil) {

    #if USE_INDIVIDUAL_SUBVIEWS_CELL

            [[NSBundle mainBundleloadNibNamed:@"IndividualSubviewsBasedApplicationCell" owner:self options:nil];

            cell = tmpCell;

            self.tmpCell = nil;

    #elif USE_COMPOSITE_SUBVIEW_CELL

            cell = [[[CompositeSubviewBasedApplicationCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"ApplicationCell"autorelease];

    #elif USE_HYBRID_CELL

            cell = [[[HybridSubviewBasedApplicationCell allocinitWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"ApplicationCell"autorelease];

    #endif

        }

    // Display dark and light background in alternate rows -- see tableView:willDisplayCell:forRowAtIndexPath:.

        cell.useDarkBackground = (indexPath.row % 2 == 0);

    // Configure the data for the cell.

        NSDictionary *dataItem = [data objectAtIndex:indexPath.row];

        cell.icon = [UIImage imageNamed:[dataItem objectForKey:@"Icon"]];

        cell.publisher = [dataItem objectForKey:@"Publisher"];

        cell.name = [dataItem objectForKey:@"Name"];

        cell.numRatings = [[dataItem objectForKey:@"NumRatings"intValue];

        cell.rating = [[dataItem objectForKey:@"Rating"floatValue];

        cell.price = [dataItem objectForKey:@"Price"];

        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

        return cell;

    }

    另外一个小朋友写的代码

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

    {

    static NSString *SimpleTableIdentifier = @"STI_SongsInfoCell";  //SimpleTableIdentifier

    //定义"视图闲置组"标识符,可以是任意字符串,只要不冲突即可

    myMusicInfoCellClass *cell = (myMusicInfoCellClass*)[tableViewdequeueReusableCellWithIdentifier:SimpleTableIdentifier];

    //创建一个视图,从标识为"STI"的闲置视图组中。

    //如果"STI"中有可用的闲置视图,则返回一个UITableViewCell,否则返回nil

    if (cell == nil) {   //如果cell=nil , 则表示sti中没有可用的闲置视图

    //创建一个视图,表示这个同STI组里面的组是同一种类型

    NSArray *nib = [[NSBundle mainBundleloadNibNamed:@"SongsInfoCell" owner:self options:nil];

    for (id oneObject in nib) 

    if ([oneObject isKindOfClass:[myMusicInfoCellClass class]]) 

    cell = (myMusicInfoCellClass*)oneObject;

    };

    //到这里为止,UITableViewCell就创建好了呃,下面就用它

    NSUInteger row = [indexPath row];

    //NSLog(@"test = %@",SearchSongsList);

    if ([SearchSongs objectAtIndex:row]==nil) {

    return nil;

    }

    //设置celllabel标签

    NSArray * myArr =  [[SearchSongs objectAtIndex:row] componentsSeparatedByString:@"<分割>"];

    //判断是否存在于播放列表之中,以确定AddedBtn是否可用

    BOOL isAlreadyAdded = NO;

    for (int i=0; i<[[myTbc playListcount]; i++) {

    if ([[[[myTbc playListobjectAtIndex:i] objectAtIndex:3isEqualToString:[myArrobjectAtIndex:3]]

    ) {

    isAlreadyAdded = YES;

    }

    }

    if (isAlreadyAdded==YES) {

    cell.AddedBtn.enabled = NO;

    else {

    cell.AddedBtn.enabled = YES;

    }

    cell.SongsName.text = [myArr objectAtIndex:0]; //myArr数组里取元素

    cell.SongsSinger.text = [myArr objectAtIndex:1];

    cell.SongsAlbum.text = [myArr objectAtIndex:2];

    cell.SongsInfo = (NSMutableArray*)myArr;

    if ([[myArr objectAtIndex:4hasSuffix:@".gif"]) {

    if ([[myArr objectAtIndex:4hasPrefix:@"d"]) 

    cell.SongsSpeed.image= [UIImage imageNamed:[myArr objectAtIndex:4]];

    };

    cell.SongsSize.text = [myArr objectAtIndex:5];

    cell.myPlayListTableView = myPlayListTableView;

    cell.myTbc = myTbc;

    cell.mySc = self;

    if ([myPlayer.nowPlayDownPageURL isEqualToString:[myArr objectAtIndex:3]]) {

    myPlayer.WorkingIndicatorView=cell.myaiv;

    }

    return cell;

    }

  • 相关阅读:
    Python界面常用GUI包
    ATSC/DVB/ISDB三大标准比较
    【MPEG】DVB / ATSC / ISDB区别
    Python判断字符串是否为字母或者数字
    MApp_ZUI_CTL_MarqueeTextWinProc字串滚动
    PWM原理及其在电源中的应用
    按键板的原理与实现 扩展GPIO
    按键板的原理与实现----ADC
    使用with语句来写一个稍微复杂sql语句,附加和子查询的性能对比
    SQL Server备份还原数据库中的小把戏
  • 原文地址:https://www.cnblogs.com/chen1987lei/p/2047953.html
Copyright © 2020-2023  润新知