Stop Truncating

Discussion in 'iOS Programming' started by duny, Mar 26, 2009.

  1. duny macrumors newbie

    duny

    Joined:
    Sep 21, 2008
    Location:
    H-Town
    #1
    I am trying to list a bio of myself (testing purposes) on my app. No matter what it always truncates the text. how can i list this all or create a box big enough to house all the text.

    Below is my code for the table.

    Code:
    - (NSInteger)tableView:(UITableView *)tblView numberOfRowsInSection:(NSInteger)section {
        return 1;
    }
    
    
    - (UITableViewCell *)tableView:(UITableView *)tblView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    	static NSString *CellIdentifier = @"Cell";
        
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil) {
            cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
        }
    	
    	switch(indexPath.section) {
    		case 0:
    	        cell.image = [UIImage imageNamed:(NSString *)rankObj.RankImage];
    			break;
    		case 1:
    			cell.text = rankObj.RankName;
    			break;
    		case 2:
    			cell.text = rankObj.RankNum;
    			break;
    		case 3:
    			cell.text = rankObj.RankShort;
    			break;
    	}
    	
    	return cell;
    }
    
    - (NSString *)tableView:(UITableView *)tblView titleForHeaderInSection:(NSInteger)section {
    	
    	NSString *sectionName = nil;
    	
    	switch (section) {
    		case 0:
    			sectionName = [NSString stringWithFormat:@"Image"];
    			break;
    		case 1:
    			sectionName = [NSString stringWithFormat:@"Name"];
    			break;
    		case 2:
    			sectionName = [NSString stringWithFormat:@"Rate"];
    			break;
    		case 3:
    			sectionName = [NSString stringWithFormat:@"Abbreviation"];
    			break;
    	}
    	
    	return sectionName;
    }
    
     

    Attached Files:

  2. fishkorp macrumors 68020

    fishkorp

    Joined:
    Apr 10, 2006
    Location:
    Ellicott City, MD
    #2
    *edit*
    Disregard my comment. It was 2:00AM, I don't know what I was looking at :p
     
  3. caveman_uk Guest

    caveman_uk

    Joined:
    Feb 17, 2003
    Location:
    Hitchin, Herts, UK
    #3
    I don't think that is germane to the problem here. To make the text multiline you need to make a custom cell or insert a UITextView into the cell. Alternatively you need to resize the text to fit the single line you have.
     
  4. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #4
    UILabel is capable of multi-line text, through the numberOfLines property. I'd look into using that.
     

Share This Page