Look like iPhone inbuilt contact applications image selection
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..
Ca开发者_如何学运维n 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.
精彩评论