English 中文(简体)
• 如何在地貌上形成像全球资源信息数据库这样的可信赖的意见?
原标题:How to create UITableView like GRID in landscape mode?

I wanna create the uitableview like this image . loading data from server and assigning the values to columns of Row. I saw the link of stack, but not helpful to me. UPDATE My code: -

#pragma mark UITableViewDelegate methods

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger) section {
    return [modelArray count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = nil;
    static NSString *AutoCompleteRowIdentifier = @"AutoCompleteRowIdentifier";
    cell = [tableView dequeueReusableCellWithIdentifier:AutoCompleteRowIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:AutoCompleteRowIdentifier] autorelease];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleGray;      
    // Configure the cell...
    RankModel *model = [modelArray objectAtIndex:indexPath.row];
    cell.textLabel.text = [NSString stringWithFormat:@"%@    %@     %@     %@     %@     %@",  model.level, model.name, model.score, model.rightAnswersCount, model.currentRank, model.country];
    return cell;
}

但是,我大麻像特定形象一样。 因此,请帮助我解决这一问题。 预先感谢。

最佳回答

Well this will require a bit more code than the method you present. My suggestion is you could create a UILabel for each of your fields, instrad of using a single NSString. Don t use cell.textLabel, but rather add your content on cell.contentView and then you can manage each label s color, background color and labels sizes. The "grid" look can be rendred by assigning a white color to contentView and assigning a green color for example to each label s background. For example, after your cell is created :

cell.contentView.backgroundColor = [UIColor clearColor];

UILabel* aLabel = [[UILabel alloc] initWithFrame:CGRectMake(100, 0.0, 100, 44)];
aLabel.tag = indexPath.row;
aLabel.textAlignment = UITextAlignmentLeft;
aLabel.textColor = [UIColor whiteColor];
aLabel.text = @"Test";
aLabel.backgroundColor = [UIColor greenColor];
[cell.contentView addSubview:aLabel];
[aLabel release];

Start your next label at 201 or more to leave an impression of a white vertical line. Keep the row index in the tag so you can manage alternate colors in :

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell
                                                        *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {

    if (indexPath.row == 0 || indexPath.row%2 == 0) {
        // use light green, get access to the labels via [cell.contentView viewWithTag:indexPath.row]
    } else {
        // use dark green   
    }
}

希望这一帮助。

问题回答

暂无回答




相关问题
Plist Hierarchy and All Option

I have a string of data in a plist, which I ve got to display, hierarchically like this: Menu>Chapter>SubChapter>item>item details This might be super simple, in my initial menu, how would I have ...

Disable iPhone table rows

Is there any way to disable the "selectibility" of a UITableView row? Example: I would like to make an appointment for a haircut at a certain time with a certain stylist. What gets displayed to a ...

Nonintrusive visual cue for uitableviewcell

I d like to mark a tableview row in some way that shows it has been clicked by the user. I have a large number of rows and want users to know if they have already visited a particular row. This same ...

TableView oval button for Index/counts

Can someone help me create an index/count button for a UITableView, like this one? iTunes http://img.skitch.com/20091107-nwyci84114dxg76wshqwgtauwn.preview.jpg Is there an Apple example, or other ...

Unable to pushViewController for subview

I have a UINavigationController and I have seperate UIViews that I switch between using a UISegmentControl. On switching the views, I add the view as a subview to my navigation controller s view: [...

热门标签