Static keyboard in uitableview - iphone

I have a UITableView that holds just two cells with a textfield in each. As my tableview is just for editing the text in these textfields I always want the keyboard to be shown static in the bottom of the screen. So in viewDidLoad I set the first textfield to become first responder.
Something I have noticed though is that when I push the UITableViewController into the UINavigationController the keyboard show up a little bit slower so you can see it animate into the screen. It would be much better if it was there already there when the uitableview shows up.
I also tried making the textfield first responder before pushing it as recommended but that didn't made the keyboard show at all:
MyTableViewController *myTableViewController = [[MyTableViewController alloc] initWithNibName:#"MyTableViewController" bundle:nil];
[myTableViewController.textField becomeFirstResponder];
[self.navigationController pushViewController:myTableViewController animated:YES];
[myTableViewController release];
How can I accomplish this?
Thanks!

take the textfield as public(set its property and synthesis) and from the place you are pushing it before that push set the first textfields to become first responder...
and then push to the controller...
There can be much more options but this is the one i can suggest... may be it help...
Happy Coding....

Related

UISearchDisplayController's table view separator lines glitch when loading inside a modal view, how do I fix it?

I'm trying to load a basic search view overlaying my navigation controller (that is, not pushed on the navigation stack). To achieve this I'm using [self presentModalViewController:vc animated:NO].
Full modal view presentation code:
- (void)searchButtonPressed
{
TMSearchViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:#"Search"];
[self presentModalViewController:vc animated:NO];
vc.searchDisplayController.searchBar.delegate = self;
}
After the modal view is presented on the screen, the following code—inside the search view's controller—is run:
- (void)viewDidAppear:(BOOL)animated
{
[self.searchDisplayController.searchBar becomeFirstResponder];
[self.searchDisplayController setActive:YES animated:NO];
}
The problem is that when the search view renders, it does the normal thing where it blacks out the table view with a transparent black view, but it doesn't appear to cover the table view's separators, which looks like this:
I really have no idea how to fix it. My best guess is that it is something to do with the modal controller's process of loading a view that I'm not understanding properly. I've tried moving the becomeFirstResponder to the viewDidLoad method. I've also tried reordering the setActive method and the becomeFirstResponder method whilst changing the setActive method to animated:NO and YES.
So far, no avail, I'm clearly not understanding something here and I'm guessing I'm using something in a way that is unintended. Please help, Thanks :)
edit: interestingly enough, when I click the blacked out table view to resignFirstResponder the searchbar, and then click inside the searchbar again to activate becomeFirstResponder it loads fine, without the glitch, how it's meant to.
Did you try self.searchDisplayController.searchResultsTableView.separatorStyle=UITableViewCellSeparatorStyleNone; ??
Okay so after hours of messing around in the code, trying to understand what I'd done wrong, I've finally found the answer, or at least a fix. (I'm still mystified as to what was actually going wrong)
I simply deleted the searchbar from the interface builder in storyboard. And replaced it with another one—which involved reconnecting the searchbar to be the searchDisplayController's searchbar property, of course.
My best guess is that Xcode for whatever reason didn't like the order in which I dragged in and connected the UI elements to interface builder/storyboard.
Hope this helps someone.

How to make transition from RootController to DetailController UITableview iphone sdk

I have a UITableView with some Cells.
I don't use NavigationController, so I'd like to use UIModalTransition to Switch from RootController, my TableViewcell, to my DetailView, but want to add a Navigation bar to attribute some actions, like Backbutton.
I don't want to use seguesTransition, I only used XIB File and any Storyboard.
I really don't know how to use the Modal Transition in TableView, anyone know how i can do it ?
Thanks.
have you tried
[self presentModalViewController:yourViewController animated:YES];
then you can set certain styles for transitions in it.
On the other view add a navigationbar and place a backbarbuttonitem and add an action to it to go back to your previous view.
Although why do you want to do it is unclear to me.
if you dont want a navigation controller on the first view, you can just set it to hidden.
self.navigationController.navigationBar.hidden = YES;
and then in the viewDidLoad of other view you can do the reverse i.e
self.navigationController.navigationBar.hidden = NO;
this is quite an easy way of achieving what you want with relatively less amount of code!!

iPhone keyboard is not showing up

My app starts on login screen. After that I use the next code to call the TabBarViewController
DMMainScreenViewController *mainScreenController = [[[DMMainScreenViewController alloc] initWithNibName:#"DMMainScreenViewController" bundle:nil] autorelease];
self.view.window.rootViewController = mainScreenController;
[self.view.window makeKeyAndVisible];
and then I move to the last tab by clicking on that.
There are 2 UITextField and one UITextView and then when I touch any of them the keyboard is not showing up and I can not also change to another TextField/TextView but I can move to another tab.
How can I fix that?
Thanks.
keyboard to show up immediately you'll need to set the text field as the first responder using the following line:
[textField becomeFirstResponder];
but in these case of tabbarViewController, as tonklon says in his answer:
If the tabbar is needed while the keyboard is visible you could only
move the tabbar above the keyboard, or resize the tabbarcontroller, so
that the tabbar remains visible.
Are you sure you need the tabbar while the keyboard is visible?
Remember a tabbar is for changing the view. Perhaps you need to
rethink your interaction design.
Are you using IB to create your views? If so, did you remember to wire up your UITextField to the File's owner so that view knows where to send the notifications that you clicked on your TextField?

Touch Focus Changing After Showing DatePicker In a Popup

I have a UIViewController. In my view (xib), I have a UIButton and a UIToolBar. On "Touch Up Inside", I have the following:
UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:ec];
nc.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalViewController:nc animated:YES];
"ec" is a UITableViewController. For this view (xib), I have three rows that consists of three text fields. In one text field, I'm setting the "inputView" to a UIDatePicker. If I put focus on this text field the datepicker shows up as it suppose to. When I set the focus on another text field, the keyboard shows up. But when I close the popup, it seems like the UIButton and UIToolBar right navigation button isn't working. Actually it is, but I have to click about an inch above the control to trigger the popup again. What gives?!
Sorry for the late post but found out the application was recalculating the view coordinates which threw it off. After fixing this, all is good.

Why doesn't my view reload?

So I have two search bars, a couple of buttons and a tableView below those (yes, all these) in one view. And I also have a navigation bar on top of it all with a back button.
For a particular operation, I remove all search bars, buttons and I display only one uitableviewcell in my view.
If I press edit, I want the whole view to be reloaded, not just the tableView but I want the view to have the search bars and buttons and the navigation screen.
I did [self.view reloadInputViews] in the IBAction of the edit button. Control goes here, but the view is just not reloaded. Why?
reloadInputViews is specifically used for views that are firstResponders. Probably self.view is not the first responder at that time. But why you want to do all this using "reloadInputViews", it wouldn't be easier to use: [self.view setNeedsLayout] ?
A better way to handle refreshing the state of a view is to abstract the configuration of your UIViewController's view's subviews into a custom method that you can call initially from viewDidLoad and again as an action of your UIbarButtonItem.
- (void)viewDidLoad {
//Specific, non repeated view setup
[self resetViewState];
}
- (void)resetViewState {
//Repeatable view setup
}
The reason it's worth making the distinction is because viewDidLoad is called automatically by the system after the view is lazy loaded. By design it's not a method that should be called multiple times per view. It will be called again if the view is discarded and recreated.
You can also move the layout of your UIViewController's subviews into viewWillLayoutSubviews if you need to do layout work, again this gets called by the system at various times.
I do not know how I get the answer myself right after posting it here on StackOverflow. Sorry for the trouble guys (sigh!)
I did [self viewDidLoad];