Why my grouped style Table View without round corner?

Discussion in 'iOS Programming' started by mikezang, Oct 1, 2010.

  1. mikezang macrumors 6502a

    Joined:
    May 22, 2010
    Location:
    Tokyo, Japan
    #1
    I made a table view in nib file and set style to grouped, then I put a TableViewCell into table view, but when I run it, I found it is no round corner in grouped table view?

    How can I show round corner?
     

    Attached Files:

  2. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    I'd look into how your background is set for your table view cell.
     
  3. mikezang thread starter macrumors 6502a

    Joined:
    May 22, 2010
    Location:
    Tokyo, Japan
    #3
    Here is my table view cell attributes.
     

    Attached Files:

  4. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #4
    Great. Is there any reason you can think of, related to the background, that would cause the rounded corners to be overlapped?
     
  5. mikezang thread starter macrumors 6502a

    Joined:
    May 22, 2010
    Location:
    Tokyo, Japan
    #5
    I am not sure what I have to do, can you tell me?
     
  6. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #6
    Think about how the layers (subviews) that make up the cell are drawn. Think about how the background colors affect that layering. It may take some creativity and pondering before you come up with the reason.
     
  7. mikezang thread starter macrumors 6502a

    Joined:
    May 22, 2010
    Location:
    Tokyo, Japan
    #7
    I don"t know. But I know if I make a grouped table view in programming, I can get round corner, so I thought if I set style to grouped in nib file, it should show as the same in programming without special settings.

    I also set background color to white, but I got the same result.

    If you don"t want to tell me result, that is ok!

    I just use it at the moment, I will do it in programming when I really need it...
     

    Attached Files:

  8. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #8
    If you look closely at the tops of your table sections you will actually see that there is rounded corners. But there is something in your settings that is causing the table sections themselves to render different as well as the cells at the bottom of the sections.

    Getting warmer...

    I'm trying to encourage you to think independently rather than posting a new thread as soon as you encounter a new issue.

    If you did in code the same thing you're doing in IB, you will get the same problem. It's not just the use of IB that is the issue.
     
  9. mikezang thread starter macrumors 6502a

    Joined:
    May 22, 2010
    Location:
    Tokyo, Japan
    #9
    Thanks for your reply.

    You know when I found problems, I think about it by myself, then I will google Internet if I couldn"t get any correct result. After that if I still have no answer, I post thread here. I spent several hours for this issue before I post

    Like you said, it is best and easy to remember if people can get result by one"s self, but if he had no skills or experience, he has no way to get right result, in this case, a detail tip or hint will let him to get answer.
     
  10. mikezang thread starter macrumors 6502a

    Joined:
    May 22, 2010
    Location:
    Tokyo, Japan
    #10
    Well, I got what I need in programming as below.
     

    Attached Files:

  11. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #11
    Well, it's hard for us to guess what you've already tried. So, rather than having us guess, I'd suggest you just tell us. This is quite helpful when your intent is getting answers.

    Which, I feel, I've already provided.

    But let me try again.

    There are two things you can try:
    1. Figure out how the background colors of your subviews are affecting the rendering of your cells.
    2. Adjust the layout of your subviews so that they don't overlap the corners.
     
  12. mikezang thread starter macrumors 6502a

    Joined:
    May 22, 2010
    Location:
    Tokyo, Japan
    #12
    I think later is what I met, but I am not sure how to change the size of my custom cell in IB, though I tried more and more.
    But in programming, it is very simple, I don't need to care about size and I got what I need, though I still hope I can do the same in IB.
     
  13. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #13
    What did you do in the programming? Can I see the code? That might help me to explain how you can achieve the same thing via IB.
     
  14. mikezang thread starter macrumors 6502a

    Joined:
    May 22, 2010
    Location:
    Tokyo, Japan
    #14
    Code as below
    Code:
    	
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:BrokerCellIdentifier] autorelease];
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 150, 25)];
        UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(200, 12, 200, 25)];
    }
    
     
  15. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #15
    All you're doing is setting the UI elements' frames. This is easily done in IB using the Size Inspector, as seen below:
     

    Attached Files:

  16. mikezang thread starter macrumors 6502a

    Joined:
    May 22, 2010
    Location:
    Tokyo, Japan
    #16
    That is done in IB, but the result is not the same as in programming, this is why I asked here.
     
  17. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #17
    Then your code must be doing something else you're not showing. Because the code you showed and the IB settings I showed do do the same thing.

    P.S. What is the difference you see?
     
  18. mikezang thread starter macrumors 6502a

    Joined:
    May 22, 2010
    Location:
    Tokyo, Japan
    #18
    What do you mean?

    The difference is with or without round corner.
    I think the different is as below, this due to different result:
    IB is to subclass UITableViewCell, and programming is to add Label/TextField to UITableViewCell.
     
  19. mikezang thread starter macrumors 6502a

    Joined:
    May 22, 2010
    Location:
    Tokyo, Japan
    #19
    Hi
    Now I got what I need in IB, like you said that is cell"s contentView background, I set it to clear color.
     

    Attached Files:

Share This Page