 |
 |
|
 |
03-13-2009, 01:43 PM
|
#1 (permalink)
|
|
Registered Member
Join Date: Feb 2009
Posts: 34
|
Question about UITableViewCell and grouped tables
OK, so I am making reasonable progress on my app, but have experienced some very strange behavior populating a UITableView with 3 sections. I should mention that I have created custom UITableViewCell views in IB and am using a table view cell factory to instantiate table cells (ala. this post: Using UITableViewCell with InterfaceBuilder « Agile Developer, Berlin, Germany)
In the top section, I have one cell with some "header" information that includes a UIImageView and some labels. in the cellForRowAtIndexPath delegate method, I get data from my model and set the text of the labels and set the image data for the UIImageView. The label text is set correctly, but when the table is rendered, the UIImageView is shifted down and to the right from where it is declared to be in IB, obscuring some of the labels in that cell.
In the second section of the table, I have a single cell with a UILabel and a UIButton. For the life of me, I cannot get the label and button text to reflect the assignments made in the cellForRowAtIndexPath delegate method. The text rendered in the simulator is the same "place holder" text that you set in IB. The text getting assigned to the label and button is correct; I have verified this in the debugger. Are there any special release/retain considerations when using the [NSString stringWithFormat:] method?
In the 3rd section, I have a list of cells that include a UIImageView and 2 labels. In these cells, the label texts are set correctly.
What could be the reason for the image shift and the label text?
Thanks,
-MrB
|
|
|
03-13-2009, 03:05 PM
|
#2 (permalink)
|
|
New Member
Join Date: Sep 2008
Posts: 1,431
|
Image shift is probably because you're not setting the autoresizeMask and/or row height correctly.
The wrong label text should be simple to figure out. Setting the correct label text depends on having the correct label and the correct text. Almost certainly one of those is nil or invalid. Possibly you're using the wrong tag or you didn't set the tag in IB.
|
|
|
03-13-2009, 03:26 PM
|
#3 (permalink)
|
|
Registered Member
Join Date: Feb 2009
Posts: 34
|
Quote:
Originally Posted by PhoneyDeveloper
Image shift is probably because you're not setting the autoresizeMask and/or row height correctly.
The wrong label text should be simple to figure out. Setting the correct label text depends on having the correct label and the correct text. Almost certainly one of those is nil or invalid. Possibly you're using the wrong tag or you didn't set the tag in IB.
|
The tag thing is part of the solution. I was tagging the stuff contained in the UITableViewCell starting with zero, but it would appear that the UITableViewCell itself reserves zero for itself, so subviews have to start at 1. The image shift is fixed now, as is the label text in the 2nd section, but the button text is still the placeholder text.
What is the "correct" way to set the title of a button using that UIControlState enumeration? Should the state really only be UIControlStateNormal, or should it be an OR'ed combination of Normal, Highlighted, and Selected?
NVM: I figured out what I was doing wrong with the UIButton title.
Thanks,
-MrB
Last edited by mrbelk; 03-13-2009 at 03:40 PM.
Reason: found solution
|
|
|
03-13-2009, 04:23 PM
|
#4 (permalink)
|
|
New Member
Join Date: Sep 2008
Posts: 1,431
|
A tag of zero is the default tag for any view that doesn't have a tag set. You need to use other values than zero.
The control state is a little confusing. You almost never want to or the enums together, at least not unless you really understand what that means.
|
|
|
03-13-2009, 04:30 PM
|
#5 (permalink)
|
|
Registered Member
Join Date: Feb 2009
Posts: 34
|
Quote:
Originally Posted by PhoneyDeveloper
A tag of zero is the default tag for any view that doesn't have a tag set. You need to use other values than zero.
The control state is a little confusing. You almost never want to or the enums together, at least not unless you really understand what that means.
|
Thanks. In the windows world, you can usually "OR" enums together that are meant to be different parts of the same behavior (enums decorated with the "Flags" attribute, like messagebox properties). I thought I had seen somewhere where the bitwise or was used w.r.t. control states. I just set the text for the Normal state, since I don't really need any different behavior for the highlighted or selected states.
Thanks again,
-MrB
|
|
|
03-13-2009, 05:19 PM
|
#6 (permalink)
|
|
New Member
Join Date: Sep 2008
Posts: 1,431
|
Yes, we in the iPhone world can OR together enums also.
It's just that in this case when you OR together the enums it means something different than what you think it means. So don't do it unless you understand it.
Set the text for the different states individually.
|
|
|
 |
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
» Advertisements |
» Online Users: 496 |
| 49 members and 447 guests |
| Abdel, ackpth, activ8, AjohnB, Alchemda, BostonMerlin, BrianSlick, Centurion Games, ChrisMayer, CoolApps, Corey, dbarrett, dda, designomatt, dmf1978, eatenbyrats, Gamer211, gonk, greenuns, Gudus, imsatasia, IphoneSdk, jharrah, Kalimba, Knertified, LemonMeringue, Link, markbuchanan, MiniRobinho, montage, msudan, naomipunkclan, NeilB, nibby, Noise, P2k, pashik, saul102, simpsonaty, Snappy, StefanL, svguerin3, tcarte04, the1nz4ne, treazer, TunaNugget, Tuszy, victorsk, ZunePod |
| Most users ever online was 779, 05-11-2009 at 10:55 AM. |
» Stats |
Members: 21,510
Threads: 35,793
Posts: 156,804
Top Poster: smasher (2,449)
|
| Welcome to our newest member, dmf1978 |
|