Table View help

Discussion in 'iOS Programming' started by ljg93, Mar 13, 2011.

  1. ljg93 macrumors member

    Joined:
    Mar 13, 2011
    #1
    hey,

    In my table view i have the code

    Code:
    
    
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    	NSMutableString *rowName = [NSMutableString string];
    	[rowName setString:[[[tableView cellForRowAtIndexPath:indexPath] textLabel] text]];
    	[rowName replaceOccurrencesOfString:@" " withString:@"" options:0 range:NSMakeRange(0, [rowName length])];
    	[rowName appendFormat:@"ViewController"];
    	
    	id newViewController = [[objc_getClass([rowName cStringUsingEncoding:NSUTF8StringEncoding]) alloc] init];
    	[self.navigationController pushViewController:newViewController animated:YES];
    	
    
    it opens a view controller with the name of the row in the table, which is great put if for one cell in my table i want it to go directly to send a email instead of going to a separate nib that has a button that says click to send email
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    I don't see a question here. Simply a statement.

    What, exactly, are you asking. What have you already tried to solve the problem you are having. What documentation have you read in your search for a solution?
     
  3. ljg93 thread starter macrumors member

    Joined:
    Mar 13, 2011
    #3

    haha my question is, how can i change that code around to make a exception for only one cell in the table all the other cells in the table go to another nib, but i want one cell to go to not a nib. how would i go about that...

    what documentation i have read- i have read a lot, i am not going to waste time and list it all

    -what have i done- nothing i do not know how to do it, hence why i asked questions ;)
     
  4. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #4
    You have the indexPath. A quick glance at the documentation will show you that has useful properties like row. Use that to form a conditional statement. This seems pretty simple. Is there some specific difficulty with this?
     
  5. ljg93 thread starter macrumors member

    Joined:
    Mar 13, 2011
    #5
    haha alright? sorry i asked a question that i did not understand i read that part of the documentation but did not understand it. maybe its understandable for you? No need to tell me that my question was basically worthless. this is my first post on this website and i am already very displeased with the "demi gods"response..
     
  6. balamw Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #6
    Please read these two very useful articles.

    http://www.mikeash.com/getting_answers.html
    http://whathaveyoutried.com/

    Do you expect any of us to:
    a) read your mind?
    b) hand you an answer?

    If you want to learn how to fish we'll help your learn, if all you want is fish, you may have to find them somewhere else.

    B
     
  7. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #7
    Have you read through the Table View Programming Guide yet? If not, you should. It will help you to gain an understanding of table views. If you have, which section do you think would have information on the problem you're trying to solve?
     
  8. ljg93 thread starter macrumors member

    Joined:
    Mar 13, 2011
    #8
    i have, i dont know where in the documentation is explains to do this though
     
  9. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #9
    You didn't see anywhere in that guide where they have a conditional based on the value of indexPath.row?
     
  10. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #10
    The documentation is not there to provide detailed, step-by-step, guides that cover all possible situations. It is there to provide the information you need to solve problems by breaking them down into smaller and smaller tasks until you can solve the problems and re-combine the solutions. This is programming. Copy and pasting code is not.
     
  11. ljg93 thread starter macrumors member

    Joined:
    Mar 13, 2011
    #11
    who said anything about copy and pasting? i was just asking where the section in the documentation that explained the did select row and index path was..
    hahah relax
     
  12. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #12
    No section explains exactly what you are seeking. But a few describe how to use a conditional based on the indexPath's row value to selectively perform some code. It is up to you to adapt this approach to solve your own problem.
     
  13. ljg93 thread starter macrumors member

    Joined:
    Mar 13, 2011
    #13
    hahah ok? no crap that is what you have to do... i was simply asking WHERE in the documentation of the table view held the basis of my problem..
    so before you and the other "demi-god" go all hot shot on me read my question first before you assume.. could you guys be any more rude about it?
     
  14. balamw Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #14
    Here's one example from the guide:

    Code:
    - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
        if (indexPath.row == 0 || indexPath.row%2 == 0) {
            UIColor *altCellColor = [UIColor colorWithWhite:0.7 alpha:0.1];
            cell.backgroundColor = altCellColor;
        }
    }
    another

    Code:
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
     
        if (indexPath.section == 0) {
            return cell0;
        }
        // section 1
        if (indexPath.row == 0) {
            return cell1;
        }
        return cell2;
    }
    Do you maybe see how you could adapt those patterns for your needs?

    EDIT: You seem to already be doing so in your other thread which seems to feed robbieduncan's assertion that you are copying and pasting code from somewhere without understanding it.

    B
     
  15. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #15
    Well, I've given you some clues as to what to search for in the guide. Or do you expect me to do the search for you and tell you where the location is? Learning to search existing documentation is a key skill in programming. You need to get used to doing it, on your own. Quite often you'll find that you get to answers much faster this way then waiting for an internet forum to respond, which isn't even guaranteed.

    Our titles on this forum have nothing to do with this issue. Please don't drag that into things.

    Um, what exactly is it that you think we are assuming?

    I wasn't trying too be rude. I was trying to guide you, via hints, to finding the answer on your own. What I find rude is the way you attacked me when I'm trying to help you.

    Sorry. I guess I'm not helping in the way you expect, so, I'm out. Good luck though.
     

Share This Page