Quote:
Originally Posted by sLesage
Hi guys,
I've been trying to get some custom drawing code working based on the Fast Scrolling examle I found on the Tweetie blog (see : Fast Scrolling in Tweetie with UITableView). I seem to get it working, but I still have some questions I can't seem to find a solution for, so I thought it would be a good idea to ask them in here.
As you can see, I'm drawing an image (logo), the title of a song and the name of an artist in a Cell. That seems to be working, but I have the following questions :
- Is there some way to indicate that the user can't select specific cells ?
- Is there some way to show ellipsis at the end of a text, or make it paint over 2 lines ? Right now if the name of the song is too big to fit in the cell, it gets painted outside the cell as well.
- Is there anything special I need to implement in order for my Table view to get painted when I rotate the device in landscape mode ? Using the simulator nothing happens when I rotate the device.
- If you do the painting yourself, would you have to draw the indicators manually as well ? Or can you still do that in code ?
That's about all the questions I have for now, but I might probably be back with a few more pretty soon.
Best regards,
Stefaan
|
Stefaan,
I can offer partial help.
For drawing your text so it doesn't go beyond your cell, you should use one of the other NSString drawing routines, like drawAtPoint:forWidth:withFont:lineBreakMode:
That call will only draw a single line of text, which sounds like what you want. I'm not sure about drawing an ellipsis at the end. There is another call, drawAtPoint:forWidth:withFont:minFontSize:actualFo ntSize:lineBreakMode:baselineAdjustment, that will shrink the font size down to fit larger titles, down to a specified minimum size. For multi-line text, you can also use drawInRect:withFont:.
As for preventing selection of your cells, there are a couple of methods for your custom cells that you can use.
You can set the allowsSelection property of the whole table view. That prevents cells from being selected. However, they will still draw as highlighted when the user clicks on them.
To prevent the highlighting, use
Code:
cell.selectionStyle = UITableViewCellSelectionStyleNone;
On each individual cell. That will prevent the cell from highlighting when the user clicks on it.
I am still struggling with getting a custom cell I'm working on to create properly at the different user interface orientations, and handle resizing on rotation. My code is updating the cell, but not doing it correctly.
Are you implementing the shouldAutorotateToInterfaceOrientation: method in your table view controller, and returning YES? That is what you need to do in order for your whole screen to rotate. Then you need to get the table view to resize correctly, which is another story.
In the iPhone 2.0 OS the call to create a cell,
initWithFrame:reuseIdentifier:
included a frame rectangle, so I knew how big my cell was going to be. I can't figure out how to tell how big my cell is in OS 3.0 The [super initWithStyle:reuseIdentifier:] method seems to always create the cell at the narrow size used for portrait orientation. I found your post while searching for help with that issue.
Regards,
Duncan C
WareTo