[PickerView Case 10-Flag Selection Interface 02 Objective-C Prophecy]

1. Okay, let’s continue to implement this flag selection interface:

notify

1. Isn’t its interface very simple? It’s just a UIPickerView and that’s it.

Then, what about each line of content displayed?

1) A text Label

2) a picture

Then everyone should be aware that what it returns should be a View, right?

In the proxy method, there is one that returns View, viewForRow:

viewForRowInComponent:

2. Then, we created a new project,

Then, I opened this project,

1) Build the interface: a PickerView and you’re done

2) Load data: load this 03flags.plist,

notify

3) There is another one: our picture resources are also put in it.

notify

So many flag pictures,

4) Then, take a look at this plist again

The flag plist is also an array containing several dictionaries, right?

notify

You can also convert a dictionary to a model,

notify

5) Return to the Controller,

notify

Lazy loading

notify

Locked up and no longer seen,

Then what,

6) Next, set its data source, proxy object,

Comply with the corresponding agreement,

notify

Implement the corresponding method:

notify

7) What is the number of groups? It is directly 1 group.

8) What about its line number: there are as many lines as there are country models.

notify

9) Finally, we say: we need to return a UIView,

pickerView: Does it have a viewForRow: method?

Some people say that there are too many methods and I can’t remember them. What should I do if I can’t remember them? There’s no need to remember them. We only need to remember the header file of its UIPickerView. Let’s go and see

notify

Click this: UIPickerView

Or click on it: DataSource, Delegate

It will be all right

There's no need to memorize it by rote.

We just need to understand this idea,

This idea is enough:

notify

2. Finally, we say, return, what view is returned for each row,

Is it set based on tableView?

Do you have an impression? When we were writing tableView earlier,

What kind of cells are returned in each row?

how is that done,

1) Step one: Create Cell

2) Step 2: Assign value to Cell, set data,

3) Part 3: Return to Cell

Then our View is the same:

1) Step one: Create View

2) Step 2: Set data for View

3) Step 3: Return to View

Someone said: Can we create a xib

This is a xib with a Label on the left:

notify

There is an ImageView on the right: it displays a picture, right?

Then, can we set data for it and finally return to View:

notify

The most important thing is this part, everything else is the same:

notify

3. Okay, everyone, what should we do:

1) The first step: What is it? Create a View. If you create a View, how do you create it?

What is our View? What do we want to do for it? Is it a xib?

notify

What should I do?

Should I create a xib first?

notify

Then, command + N,

notify

User Interface:View

Bring a View directly in:

Then, Name:

notify

Name:HMFlagView.xib

notify

Now, our xib has:

notify

Put it up

notify

In this case, I would still add a Group:

notify

1)Group Name:View,

notify

2)Group Name:Controller,

3)Group Name:Other,

4)Group Name:Model,

notify

These two are our models: HMFlag.h, HMFlag.m

notify

AppDelegate.h, AppDelegate.m, are these two placed in Other?

In the controller, press Shift and change these three:

notify

Put it in the controller

notify

Do some teachers put the Storyboard in View?

HMFlagView.xib: Put this in View

notify

Oh:

notify

As for the placement of this file, you can place it according to your personal habits, but the others are basically the same structure.

Then put the following three into:

notify

Put it in SupportingFiles

notify

4. Okay, let’s continue, now we have this xib

Then, should we change it:

notify

Let’s first add constraints to it: Change this Size: to freedom

notify

1) Size: Change it to freedom. Can its size be modified?

2) Then, change this Status Bar: to None,

notify

battery is

Guess you like

Origin blog.csdn.net/madoca/article/details/132896367