This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Table View scroll when text field begin editing iphone
I have loaded many UITextFields in UITableview. Maximum i have 15 UITextFields in UITableView cells. I want to move(Scroll) up the the Cell when the Keyboard/UIActionSheet(UIPickerView) appears. Please suggest/guide me any sample code to solve this problem. Thanks in advance.
You can use the sample code to take some hint.
https://github.com/michaeltyson/TPKeyboardAvoiding
I have used it in my projects as well.Hope it helps
Please try below code in -textFieldShouldBeginEditing ....
self.tblView.frame= CGRectMake(self.tblView.frame.origin.x, self.tblView.frame.origin.y, self.tblView.frame.size.width, self.tblView.frame.size.height - 190);
NSIndexPath *indexPath =[NSIndexPath indexPathForRow:nIndex inSection:nSectionIndex];
[self.tblView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:YES];
Thanks
Check out the below link from apple documentation with complete explanation and required code
They have talked about for registering for the keyboard appear and disappear notification and alter the rect of your underlaying UIView in the notification method for more go through the below URL.
Moving Content That Is Located Under the Keyboard
Related
Say I have an iPhone app using a tableview. As shown below, if I click the edit button I go into edit mode. Then I have the option to delete or add. So far so good, and all of my code is working. However, what about modifying one the the cells?
The first cell, for example, is Chevy. Say I want to change it to Ford. How can I edit a cell's value while in edit mode?
Is there another button I can add called "Change"? If so what would the code be for this?
Having looked around Google I can't find any results for this type of question. Does anyone know any good tutorials? Or at the very least, can someone provide some ideas and perhaps code samples to get started?
Depends how you want the user experience to be. One option would be to use the TableView delegate method didSelectRowAtIndexPath to take the user to another page with a text field and a save button.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
UIViewController* myEditCarDetailsViewController = [[UIViewController alloc] init]
[self.navigationController pushViewController:myEditCarDetailsViewController animated:YES];
}
Once the user clicked save, you just need to update the datasource and call reloadData on the tableView.
Another option would be to make a custom tableView cell that has a textField in it that you set to editable when the table is in edit mode.
I'm guessing you were hoping for an in built apple way. I don't know of one, but it may exist
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
The zoom for uiscrollview isn’t working
I posted a question yesterday, because the zoom for the UIScrollView isn't working. When pressing on a button, a UIScrollView appears, that contains an UIImage, but the problem is that I can't zoom by clicking or double-clicking on the image. I made a debug and the method
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
doesn't get called. The question can be found here
Sorry for asking the same question again. Thank you in advance. I wish you all the best!
Try changing the property UserInteractionEnabled of image view to YES. May be that can help
Did u set the delegate of scrollview.First check it once...if delegate returns nil, nothing happens....so first set the delegate of UIScrollview.
This question already has an answer here:
Closed 11 years ago.
Possible Duplicate:
Change view when tableview cell is pressed?
I have a UITableView with several rows, and I'd like to have it so that tapping on each row would take you to a different view. How can I do this?
if you have the user id stored in the same array as your TableView data you could well use indexPath to access this information and pass it off to another control like a UIViewController. eg.
NSDictionary *selectedUser = [MyTableViewDataArray objectAtIndex:indexPath.row];
MyUserViewController *userVController = [[MyUserViewController alloc] initWithUser:selectedUser];
you could then push this viewcontroller onto the stack
[self.navigationController pushViewController:userVController animated:YES];
[userViewController release];
obviously this is a pseudo example but should help you.
Tim
Create a new project from the Navigation-based application template and XCode will generate you the example code.
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Tasks with my UIImageView
How can i highlight my UIImageview and display a deleteButton(cross button) on top of the imageview when user touching the UIImageview?.
You need to create a IBAction that adds the cross button and wire it to the touchDown event in interface builder. You could probably make a timer that will give it a couple seconds before activating.
Option 2: read about gestureRecognizers, they are very simple and I learned them in a couple hours.
http://developer.apple.com/library/ios/#documentation/EventHandling/Conceptual/EventHandlingiPhoneOS/GestureRecognizers/GestureRecognizers.html <-- all about recogizers
It's pretty straight forward. Use
UILongPressGestureRecognizer
In the methods below write a code for detecting gestures and popping up a delete button.
- (void)handleGesture; //or
- (void)handleGesture:(UIGestureRecognizer *)gestureRecognizer;
For deleting use
- (void)removeTarget:(id)target action:(SEL)action
I want to hide(or notshowing) Selected row in tableview....
i am using [self.tableView deselectRowAtIndexPath:indexPath animated:NO];
But its doesnot work.
Can anyone help me?
Do you want to remove it or deselect it? To remove it, you need to remove it from your datasource reference, then call
[myDelegate tableViewSelectionDidChange:NSTableViewSelectionDidChangeNotification];
More info is in the Table View programming guide:
http://developer.apple.com/documentation/Cocoa/Conceptual/TableView/Tasks/UsingTableDataSource.html#//apple_ref/doc/uid/20000117