how can you create a login screen like the iPhone facebook app? - iphone

The Facebook app for the iPhone has a great username/password setup where it almost looks like it is a uitableview with UITextField's inside the two rows, is this how it is done? Or would it be something different to this altogether?
If it is a tableview, how can I access the textfields inside the tableview once the user hits the Login button? Is there a quick way to iterate over the cells in a tableview?
A simple one, I know, but I didnt want to implement an elaborate tableview if I didnt need to...

The source: https://github.com/c99koder/lastfm-iphone
Edited: It's possible you customize the UITableViewCell and put a UITextField inside. However, there is an even easy way to achieve this, since the login / signup page would almost always be static. See below.
LastFM for iPhone used a similar login / signup page design. And they open-sourced their code. Take a look at the nib file and you will know how LastFM did this. :-)
Screenshot 1: original
Screenshot 2: after I removed some of the background png files.

Create a tableview controller and go to the xib file -> attributes inspector->tableview and select "group styled" instead of plain. Then u can customize the tableview cells in the code by adding the textfields for username and password. Then create a new UIView and set the view to the tableview's footer view for the login button.
For more explanation regarding the same, go through the answer for this question.
Table view in iPhone in grouped style

It looks like it's not using a UITableView at all (otherwise, you'd be able to scroll the page up and down). It's just two UITextFields over custom backgrounds (or with custom backgrounds).
Now, if you wanted to use a UITableView, what you could do is store as variables the UITextFields within the UITableViewCells. Then, when the person clicks a login button, you just get the text value from the UITextFields.
But, again, if you wanted to emulate the Facebook look, you don't need to bother with the UITableView.
Hope this helps!

Alright, now that I understand your question (thanks #Jonathan!), yes it does look like it is a tableview using custom UITableViewCells with a UITextField.
After creating the custom cell with a UITextField you can assign your view controller as the UITextField delegate and access the values at various points through the delegate methods:
– textFieldShouldBeginEditing:
– textFieldDidBeginEditing:
– textFieldShouldEndEditing:
– textFieldDidEndEditing:
As an example, in your textFieldShouldReturn:, you can grab a reference to the indexPath of that cell with :
NSIndexPath *indexPath = [self.loginTable indexPathForCell:(MemberLoginCell*)[[textField superview] superview]];
And then to the cell with:
MemberLoginCell *cell = (MemberLoginCell*)[self.loginTable cellForRowAtIndexPath:indexPath];
Or simply grab the textField.text value and assign it to an NSString that can be passed to your LOGIN method as required.

I know there's already an accepted answer, but I created a facebook-type login page, using a UITableView. The code is here on github

Related

UITableView inside a Custom UITableViewCell

In my app I have a TableView that displays a list of Items. Tapping on any cell will expand it and will display information related to tapped item. I want to display the information in tabular form, will it be a good approach to have a UITableView inside a UITableViewCell?
Have a look to my answer in this post.
I think it is what you are looking for.
I am suggesting u to go for master-detail view controllers :) ,for your question "have a UITableView inside a UITableViewCell " for this u need to subclass the UITableviewCell and in that cell u put or add another tableview by managing datasource and delegate in custom cell see my answer it shows how to add tableview within the custom UITableView cell see hear and before that u hav to incerease the row height for each cell i did not included it, "one thing i created all programatically not used xib" :) hope u get some idea .

How to create login and password fields same as in facebook app for iOS

I want to create login and password fields same as in facebook app for iOS. Here is screenshot:
Best way I think you need to create a Custom TableView Cell and Add a textField under it with textField borderStyle being UITextBorderStyleNone. Also you can give a placeholder string as "Email" and "Password" in respective textFields.
EDIT:
You can have two sections in tableView. Section 0 will contain textFields and Section 1 will have Login Button.
For the Login button, you just need to give the background color to contentView of the cell to make it work as a button. And didSelectRowAtIndexPath: for Section 1 & Row 0 (i.e Login button) will work like button's TouchUp Inside Event.
EDIT-1:
Thanks to #MichaelFrederick suggestion, I got a better solution where in we can create a view with Login button in it and return the view from below method:
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
return yourLoginButtonView;
}
Let me know if you need more help.
Hope this helps
That looks like a customised UITableView used as a subview. But there are lots of ways of going about this, from using plain old custom UIViews to having the shape as a background, with text input overlaid on top.

iPhone app: UITableViewController with UITextView in a cell, can't get rid of keyboard

I know this question has been asked before but I couldn't find an answer that applied to my problem.
I've got a UITableViewController that has a third row that is filled with a UITextView.
I'm quite happy with the way it looks and the way text is typed into it.
However I'm unable to find a way of getting rid of the keyboard once the user is done entering text. I'd like to be able to use the return button for actual \n in the text.
I've gotten this far that pressing the upper two rows will make the textView te resignFirstTransponder but is there a way to catch a tap on the greyish background?
This is all in a UITableViewController loaded from a nib file.
Btw, I'm quite new to iOS programming so the more elaborate your answer the better :)
Thanks!
A pattern many apps follow is to show a horizontal bar with buttons on it just above the keyboard. It can contain a done button clicking on which you can hide the keyboard. And of course you will have to create that horizontal view yourself.
Another way would be to enable a touch recognizer elsewhere, and on a tap outside hide the keyboard
One alternative would be to add a toolbar to the keyboard with something like a "done" button that will dismiss it. You can find some sample code about that here. One second approach would be to dismiss the keyboard when the user selects a different cell or even when the tableView scrolls. In order to do that, you can add relevant code in -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath or in -(void)scrollViewDidScroll:(UIScrollView *)scrollView respectively.
This can get a little tricky if your new at iOS. The way I handle a UITextView in a UITableViewCell is I make a custom UITableViewCell subclass with an outlet for the UITextView.
Then set your cell in interface builder to be of that subclass. In the CellForRowAtIndexPath:
set the delegate to self. Then in the DidSelectRowAtIndexPath you call the delegate for the TextView based on the indexPath, this way the keyBoard will dismiss for the correct row if you touch the background. If you want it to dismiss when the user touches any cell just call the delegate without specifying the indexPath. The Delegate is TextViewShouldEndEditing:.Ill post some code if you want.

Calling UITableView's cellForRowAtIndexPath: for just one iteration

When attempting to create a form with UITextFields, it appears that cellForRowAtIndexPath: gets called every time a user scrolls up and down the tableView. When this happens, a new UITextField is created, and the old UITextFields are no longer visible. Is there a way for the cellForRowAtIndexPath: method to be called for just one iteration?
Check the docs for UITableViewCell, especially A Closer Look at Table-View Cells and the section about static cell content.
Perhaps you might consider a simple UIScrollView rather than a UITableView? It's difficult to tell what you're trying to accomplish here. Perhaps add a bit more detail to your question.
Create UITableViewCell nibs in Interface Builder with UITextFields and link all of the objects with the viewController class.

Question regarding updating a UITableViewCell on the iPhone

I'm looking to do something simple such as drilling down on a particular UITableViewCell, which brings up a detail view controller. Within there, the user has the capability to change the attribute for the model underneath the cell. For instance, If I'm displaying a list of quotes, and a user clicks on a quote and favorites it in the child controller, I want to be able to display an image which was hidden now that it's favorited placed, a star perhaps. What's the easiest way to update one particular UITableViewCell in such as fashion? Is it best to reference the selected UITableViewCell into the child controller and couple them in such a fashion? How is something like this done?
Thanks.
It's probably easier to simply update your model object and then call [tableView reloadData];.
Then change your drawing code to account for the changes and display your hidden images or whatever.
setNeedsLayout did it for me.
For a complete code example have a look at the SQLite Books project on ADC.
To redraw a specific cell you should find its rectangle (rectForRowAtIndexPath) then call setNeedsDisplayInRect on the UITableView with this rectangle.