How can you create a login screen, for example, an application for facebook facebook?

The Facebook app for iPhone has an excellent username and password setting, where it almost looks like it's a uitableview with a UITextField inside two lines, is that so? Or would it be completely different?

If this is a table view, how can I access the text fields inside the table as soon as the user clicks the login button? Is there a quick way to iterate over cells in a table?

Simple, I know, but I did not want to implement a complex table if I did not need to ...

+4
source share
5 answers

Source : https://github.com/c99koder/lastfm-iphone

Edited: You may have configured a UITableViewCell and placed a UITextField inside. However, there is even an easy way to achieve this, since the login / registration page will almost always be static. See below.

LastFM for iPhone used a similar login / registration page design. And they opened their code. Take a look at the nib file and you will find out how LastFM did it. :-)

  • Screenshot 1: original
  • Screenshot 2: after deleting some background png files.

enter image description hereenter image description here

+4
source

Create a table view controller and go to xib -> attribute inspector-> tableview and select "group styled" instead of plain. You can then customize the tableview cells in the code by adding text fields for the username and password. Then create a new UIView and set the table footer view for the login button.

For a more detailed explanation on this, answer this question.

IPhone table view in grouped style

+3
source

It doesn't seem to use a UITableView at all (otherwise, you can scroll up and down the page). These are just two UITextField on top of custom backgrounds (or using custom backgrounds).

Now, if you want to use UITableView , then you can save UITextField as variables within UITableViewCell s. Then, when the user clicks the login button, you get the text value from UITextField s.

But, again, if you want to emulate the look of Facebook, you do not need to worry about the UITableView .

Hope this helps!

+1
source

Ok, now that I understand your question (thanks @Jonathan!), Yes, it looks like this is a table view using custom UITableViewCells with a UITextField.

After creating a custom cell using UITextField, you can assign your view controller as a UITextField delegate and access the values ​​at different points through the delegation methods:

 – textFieldShouldBeginEditing: – textFieldDidBeginEditing: – textFieldShouldEndEditing: – textFieldDidEndEditing: 

As an example, in textFieldShouldReturn: you can get a link to the indexPath of this cell with:

NSIndexPath *indexPath = [self.loginTable indexPathForCell:(MemberLoginCell*)[[textField superview] superview]];

And then into the cell with:

MemberLoginCell *cell = (MemberLoginCell*)[self.loginTable cellForRowAtIndexPath:indexPath];

Or just take the value of textField.text and assign it to NSString, which can be passed to your LOGIN method as needed.

0
source

I know the answer has already been accepted, but I created a facebook login page using a UITableView. Code here on github

0
source

Source: https://habr.com/ru/post/1340562/


All Articles