i've done a feed reader with a UITableView structure, i would to change the UITextLabel TextColor after an user click on it (like reeader app)
could someone help me?
thank you,
devskip
If you're using a built-in table view cell style, all you have to do is set the highlightedTextColor of the cell's labels. Then, when the cell is highlighted, the labels will change color as appropriate.
If you're using a custom UITableViewCell subclass, you can still set the highlightedTextColor, but you must also override setHighlighted:animated: to update the highlighted property of any labels.
Related
I want to reuse views and code
Is it ok to add a UITableViewCell as a subview to a common view and not in UITableView?
Is it a good idea?
I don't think it's a good idea. UITableViewCell is made to serve as a cell and nothing else. Just like UIButton is made to be a clickable button. But you might think "well the button looks good, shouldn't i reuse it just as a subview?". No, you shouldn't do that. Button is a button, cell is a cell and so on. If you want to reuse your code then you should provide a kind of custom UIView and let it be subview for your cell or anything you want
I have a view controller that I have a static view up at the top with a button and a tableview that is under it. I'm attempting to create custom cells in the tableview, but I cannot add labels or anything to the cell. Storyboard only allows me to add the labels to the original view or the tableview (but not the cell). How can I get around this?
Here's a picture for reference.
Out of pure "trying everything" I got it fixed by manually dragging a cell into the view and not using the auto generated prototype cells by xcode. It looks like it was a bug with xcode where it's auto generated prototype cells would not let any interaction happen. To fix it, I dragged a UITableView cell from the object list into the tableview and I was able to edit that just fine. Hope this helps someone else out.
on my last cell is a dynamic textview. With bigger contentSize it will be stay on top of the tableview (to see it, while you fill it on keyboard), but if the textview and also the cell is going to be dynamically bigger: [tableview beginupdates] and [tableview endUpdates] will delete my contentSize. And after that it is scrolling it down to bottom of tableview.
Any ideas how to scroll the cell to the top, and create the cell also dynamically without changes on contentSize? maybe I'm thinking on the right way, ideas?
EDIT
Hmm..not any "correct" solution found...the best way for this purpose is to try set any new cells or sections below the textview to get this cell easy to top of the view. After this its easy to use it with beginUpdates and endUpdates. The cursor will be always in the textview, textview will be dynamically bigger also the cell, so the only easy way.
Another option is to set the uitableview as a subview of another scrollview (uitableview himself has one) to scroll up an down in the new scrollview.
Thanks for help.
From my experience, Text views in cells is a very tricky issue. I recommend just using the free Sensible TableView framework, which has text view cells available out of the box.
I'm working on an interface prototype and am using a storyboard to do so. Part of the prototype involves setting the detail UILabel for UITableView cells to a certain color. I would like to avoid having to manually recolor every label within a storyboard.
I found that I can use:
[[UILabel appearanceWhenContainedIn:[UITableViewCell class], nil]
setTextColor:[UIColor cyanColor]];
To change the appearance of labels within tableview cells. Is there a way to further refine this code to only apply to detail tableview labels? Currently it changes both textLabel and detailTextLabel of UITableViewCell.
Thank you!
You could trick around this by subclassing the cells in the detail view, then use
[[UILabel appearanceWhenContainedIn:[YOUR_UITableViewCell class], nil]
setTextColor:[UIColor other_colr]];
If you want to keep using the appearance proxy, you will have to create a custom table view cell and a new label.
In the storyboard editor you set the style property of your UITableCell to "custom".
Drag two label to the table view cell and configure it like you want it.
Create a new class that inherits from UITableViewCell and make IBOutlets for every label.
In the storyboard editor you set the class of the table view cell to the table view cell class you just created. Connect the outlets to the labels. Actually this is enough, because you can configure the appearance of the cells in the storyboard as well. If you want to configure the label through code you have to execute the following steps as well.
Create a new class that inherits from UILabel and leave it as is.
Go back to the storyboard editor and select the detailtextlabel and change the class to the label class you just create.
If you want more information on how to create your own table view cells see Table View Programming Guide for IOS
I'm subclassing UITableViewCell and using Quartz 2D to draw the elements of the cells in the drawContent view method. In my table view delegate's tableView:cellForRowAtIndexPath, I'm also inserting a UIImageView as a subview to the cell, but the image doesn't appear until the cell is selected. I'm suspicious of the backgroundView and selectedBackground view here, but I'm not sure what I can do to ensure the image is always visible. Here's what it looks like when then cell is selected...
alt text http://www.irovr.com/stackoverflow/tableviewcell.png
I want it to also look this way when the cell isn't selected, but it currently appears as black. My table view background color is black. The cell's background is clear.
Figured it out. I was adding the image to the overall table cell view. I had to add a new view property to my subclass and insert it at the 0 index. Otherwise, the superclass was laying out the views the way it was designed to and interfered with my image.