iphone - 分组的 UITableView 中未显示文本

标签 iphone ios sdk uitableview

没有显示 UITableView 中每个单元格的文本,我终究无法弄清楚原因。我在 TableView 中有 3 个部分,这些部分显示正确,每个部分的行数也是如此。但是,所有部分的每一行内的文本都是空的。我的代码是:

This is how its looking =[

- (void)viewDidLoad    {
            [super viewDidLoad];
            listofsections = [[NSMutableArray alloc] init];

            NSArray *shuffle = [NSArray arrayWithObjects:
                                           @"Display words in alphabetical order", @"Display words in shuffled order", nil];
            NSDictionary *shuffleDict = [NSDictionary dictionaryWithObject:shuffle forKey:@"Object Key"];

            NSArray *wordFilter = [NSArray arrayWithObjects:
                                @"Show all words", @"Show words not yet appeared", @"Show words marked correct", @"Show words marked incorrect", @"Show words marked as favorite", @"Show words saved for later", nil];
            NSDictionary *wordFilterDict = [NSDictionary dictionaryWithObject:wordFilter forKey:@"Object Key"];

            NSArray *wordDisplay = [NSArray arrayWithObjects:
                                @"Display words first", @"Display definition first", nil];
            NSDictionary *wordDisplayDict = [NSDictionary dictionaryWithObject:wordDisplay forKey:@"Object Key"];

            [listofsections addObject:shuffleDict];
            [listofsections addObject:wordFilterDict];
            [listofsections addObject:wordDisplayDict];

            // Do any additional setup after loading the view from its nib.
        }

    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

        return [listofsections count];
    }


    // Customize the number of rows in the table view.
    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

        //Number of rows it should expect should be based on the section
        NSDictionary *dictionary = [listofsections objectAtIndex:section];
        NSArray *array = [dictionary objectForKey:@"Object Key"];
        return [array count];
    }

    - (UITableViewCellAccessoryType)tableView:(UITableView *)tableView accessoryTypeForRowWithIndexPath:(NSIndexPath *)indexPath {

        //return UITableViewCellAccessoryDetailDisclosureButton;
        return UITableViewCellAccessoryNone;
    }


    - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {


        if(section == 0) {
            return @"Word Display Order";
        }
        if (section == 1) {
            return @"Word Filter";
        }
        else 
            return @"Display Selection";


    }


    // Customize the appearance of table view cells.
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

        static NSString *CellIdentifier = @"Cell";

        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil) {
            cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
        }


        // Set up the cell...

        //First get the dictionary object
        NSDictionary *dictionary = [listofsections objectAtIndex:indexPath.section];
        NSArray *array = [dictionary objectForKey:@"Countries"];
        NSString *cellValue = [array objectAtIndex:indexPath.row];
        cell.textLabel.text = cellValue;


        return cell;
    }

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
        [tableView deselectRowAtIndexPath:indexPath animated:YES];
    }

最佳答案

您创建的词典没有您在其中使用的键@"Countries" - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

关于iphone - 分组的 UITableView 中未显示文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8704650/

相关文章:

android - 如果 2.3 android 应用程序不使用 2.3 中引入的任何额外 API,它会在 2.2 上运行吗?

java - 如何在 Android 中处理玩家回合?

iphone - 是否可以打印屏幕或将屏幕的某些部分保存在图像中?

iphone - 如何在没有沙盒的情况下测试应用程序购买

objective-c - 有没有办法检测当前可见的 UIView?

ios - XMPP IOS Openfire 在发送元素后断开连接

php - Google Cloud SDK 安装程序无法在 Windows 上完成组件安装

ios - xcode - webview 内容显示在状态栏中

android - 用于移动编程的物理 Flex 库

ios - imageWithRenderingMode 不适用于 setImageWithUrl(对于 tintColor)