I would like to do a design similar to iPhone outbox.
It displays 3 lines of text in a single column. The first line is large and bold, the second line is of normal size and font and third one is grey color.
Also a time is displayed in the first line with a different font color.
I know to create a two line display using subtitle cell type but i am not sure how the outbox design is achieved.
Have they used a custom view with different labels and put that view inside the cell?
Thanks
You are on the right track. Create three custom labels and add them as subview to the cell.
You can either do that directly in your
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
or by subclassing UITableViewCell. Alternatively, you can design your custom cell in Interface Builder.
Related
I am coding an iPhone App in which am using a UITableView which has several sections ; each section has a header & then its rows like this:
I can do the row styles correctly, by using custom UITableViewCell objects, but how do I do the header? As you can see:
the header has the text centered with two lines drawn from it, one on each side
The header color is different
also the corners of each section are rounded
how do I achieve this, either programmatically or using Storyboard?
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
This method, implemented as part of your UITableViewDelegate, is intended to allow you to to create custom views for headers in UITableViews. You can return any UIView from that method, whether it's one that you want to create in Interface Builder, or in code.
I'm using aqgridview to create a book-shelf like UI.
I can place image and title for image fine (with the ImageDemo example provided in aqgridview).
I want to place 'shelf' image where the image title is. (as in http://itunes.apple.com/ca/app/rivet-for-ipad/id375055319?mt=8)
I can set the background color of the label for title but the shelf background image won't be there where there's no cell in the first place.
Hence shelf image doesn't cover the entire screen width.
How can I stretch the shelf image?
Thank you
i'm also using AQGridView for a book grid with shelves, i found the best and fastest way to do this is simply use a UITableView.
Create a UITableView and add the shelves images as rows (Configure UITableViewCell)
Set the AQGridView backgroundView to the UITableView
_gridView.backgroundView = _tableView
you can use
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
to use different shelf graphics for different shelfes
but i'm guessing you already found way by now.
I am display some long text in a cell, and resizing the height of the cell using heightForRowAtIndexPath. However, when the text is displayed it is running into the area used by the (blank) disclosure indicator.
When such a row is selected, and the checkmark is displayed, the text reformats itself to not use the indicator area, causing a visual effect I do not want.
If there was a UITableViewCellAccessoryBlank accessory type (rather than UITableViewCellAccessoryNone), maybe the text wouldn't wrap into that area when displaying. Am I going to have to create a custom cell and layout my own label, or is there a simpler way?
First of all, I don't see a property call UITableViewCellAccessoryBlank in the UITableView Cell class reference so I don't think this will work.
I think you have 2 options :
Create a custom cell, like you suggest.
Configure the textLabel of your cell to change his contentMode.
I read this in UILabel class reference :
The default content mode of the
UILabel class is
UIViewContentModeRedraw. This mode
causes the view to redraw its contents
every time its bounding rectangle
changes. You can change this mode by
modifying the inherited contentMode
property of the class.
I suppose that the textLabel bounds change every time you change the accessory type, so by default it redraw himself.
You can try this in your - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath method :
cell.textLabel.contentMode = UiViewSomeContentMode;
Content mode list can be found here. I'm not sure which one you should use so I let you try.
EDIT
It seems that contentMode is not working. So you should use a custom UITableViewCell to prevent any animation when adding an accessoryView.
Hope this helps !
I have created an application in which i have to add users to the sqlite database.
Now the problem is I want the look of the standard iPhone Contact application Where while adding user we have the width of first cell smaller than other cells and the image before that cell..
Can you please give me the idea how such thing is possible.
How to make one cell small and rest others of normal size..
Thanks for any help in advance
There are three UITableViewDelegate messages you can listen for to adjust height
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
However, even thought I didn't write Contacts.app I have a feeling they are also using
- (NSInteger)tableView:(UITableView *)tableView indentationLevelForRowAtIndexPath:(NSIndexPath *)indexPath
To adjust the views as well. Remember, you don't have to pack everything into a single monolithic custom table view cell. You can create multiple custom table view cells and load them each appropriately depending on the index path.
The contact detail view is a grouped tableview. Each cluster of cells is a section. The top section is a single custom cell with two subviews that look like squashed tableview cells. The left view shows the contact's photo. The right view shows the name.
To reproduce, create a custom UITableView subclass and lay it out like you want either programmatically or in Interface Builder. Then in the tableview delegate's cellForRowAtIndexPath check indexPath.section and return the proper row for the section.
It appears that the Contacts app uses a custom tableHeaderView when presenting the contact details with an image and label. A similar implementation is included in the sample project iPhoneCoreDataRecipes. The RecipeDetailView loads a separate nib in tableViewHeaderView that is used to set the tableView.tableHeaderView property. Have a look at RecipeDetailViewController.{h,m} and DetailHeaderView.xib. When the Contacts app switches to editing mode, the headerView appears to be swapped out for another view that has a button and a tableView with a single cell. This will allow you to set up a separate tableViewDelegate to handle the Name parts of the contact and a delegate to handle the address / telephony details.
I have a UITableView fed from some arrays.
When the user selects a specific row, for example row 3, i would like to add a checkmark and change the text color (not the selectedTextColor, that i have already managed) of that row to red. I would simultaneously like to change the text color of, for example row 5, to green.
How can this be accomplished?
As you might understand, i am working on a prototype quiz app.
Cheers, Adam
Use the UITableViewCellDelegate and specifically the method:
- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath
In this method check that the row about to be selected is one of the specific row that you want to change the text color for. To get the specific cell use cellForRowAtIndexPath and then change the color of the text by the textLabel property and its textColor property.
Don't forget to change back the color when the row is deselected by using the willDeselectRowAtIndexPath...