Question about iPad/iPhone controls - iphone

On the iPhone/iPad in the general settings they have a list of itms that display a '>' at the right hand side. When pressed it slides to another view.
Is this a control from the object palette? If so, which control? If not, what is the best way to achieve similar functionality.
I have looked at a lot of the samples on the Apple Dev site, but I cannot find a control like that, or at least I don't remember seeing it.
Any help on this foolish question is appreciated!! -:)
Thanks

Any time you see a view that is a scrollable list of items, you are looking at a UITableView, and each item in the list is defined using a UITableViewCell. To make the UITableViewCell show the '>', you simply have to set its 'accessoryType' to 'UITableViewCellAccessoryTypeDisclosureIndicator'.
This only draws the '>', it doesn't slide in the other view. However, when a user selects a UITableViewCell, it will call a function on its delegate:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;
In here, you will write the logic that slides in the new view controller (using UINavigationController's -pushViewController:animated:).
To learn more about how to use UITableView, I would highly suggest reading through the UITableView programming guide. It also links to downloadable projects with sample code.

You probably mean the combination of a UITableViewController and a UINavigationController. Create a new "navigation based app" to check out how it works & have fun. :)
Both are available in IB under the Controllers section.

The control you're looking for is a UITableview with disclosure indicators. To get the disclosure indicators (either the grey chevrons or the blue buttons), set editingAccessoryType for each tableview cell. That will give you a '>' on the right side of each item in your tableview.
When you tap on one of the '>'s, the tableview's delegate will have this method called:
- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
This is different from the method that is called if you tap anywhere else on the row:
- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
As dominostars said, you create another view and use UIViewController's pushViewController method to have another view slide in from the right.

Related

Pinterest's first tab is UITableView or UIWebView?

I wonder which view is used in the next image?
UITableView or UIWebView?
I always wondered how one can tell if a view is embedded inside a web view or not.
Anyway, anyone knows the answer for this specific view?
You can set individual height to individual UITableViewCell using this delegate Method
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;

drag and drop in uitableview

I am currently developing an application in which a user is displayed a list in the form of a tableview. when the user selects a particular row, he/she can drag it to another row. When that happens an alert is displayed giving some specific information.Any idea as to how it can be done.?
What I am doing is that I am using gesture recognizers.When a particular row is selected, an image of the selected row is made which then is dragged to the specific table view cell.I am able to move the image but my problem is that if I dont put the imageView under a UIView, the dragging stuff does not happen.....
My dragging code is based on apple's touches sample code .
Update:
After trying for some time, I am able to almost implement this.I still have one doubt though.. I am creating an image of a cell once it is tapped.Then UIPanGestureRecognizer has been added to that imageView which it turn makes its movement possible .The only problem is how can I know on which cell the image has been dropped?
you should implement:
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
which will return YES, and also implememt:
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
//do whatever u want after row has been moved
}
and then call this function from tableView:
- (void)setEditing:(BOOL)editing animated:(BOOL)animated
to enter to edit mode.
This is a sample of an application with cells drag-n-drop in UITableView using native methods of delegate and dataSource of UITableView.
https://github.com/coderDove/UITableView-Drag-n-Drop

UITableView: delete section controls

Is there a way to add delete controls, like in UITableViewCell, on a table section? I see two ways:
Use table cell instead of sections.
Write own UIView section class, which will show delete controls.
Regarding the first way - as I think, it could be an easiest way in my situation.
The second way may be better from the implementation point of view, but it will take more time.
May be I missed another way? Any suggestions?
The only way I see is to provide your UITableViewController Delegate or Subclass with the method called:
- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
This gives you the power to display any kind of UIView as a section-header. within this view you can place controls that enable the user to delete sections.
I hope this helps a bit.

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..
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.

Change UITableViewCell appearance when drag handle is pressed

I'd like to change the appearance of a cell when the user tap the drag handle.
I searched in the documentation, forums and google, but I can't find a method or an event that say when the drag icon is pressed.
Any help will be appreciated!
Thanks
Does this function help:
// Allows customization of the target row for a particular row as it is being moved/reordered
- (NSIndexPath *)tableView:(UITableView *)tableView targetIndexPathForMoveFromRowAtIndexPath:(NSIndexPath *)sourceIndexPath toProposedIndexPath:(NSIndexPath *)proposedDestinationIndexPath;
It doesn't seem to fire until the cell has been dragged about half way into another cell, though.
It is the only indication I could find that a cell is moving.