Home >Backend Development >PHP Tutorial >Shangxuetang ios primary video material sharing
"Shangxuetang ios Elementary Video Tutorial" is Shangxuetang's complete set of video tutorials on Objective-C language from basic introduction to advanced proficiency. Objective-C is an essential language for iOS development. The course will provide in-depth coverage of Objective-C language. Detailed explanation, mainly explaining the basic syntax of Objective-C, object-oriented programming ideas, encapsulation (declaration and implementation of classes, getter and setter methods, properties), memory management, inheritance, polymorphism, classification, protocol, block, NSNumber, characters String, array, dictionary, date, file management, copy, etc.
Video playback address: http://www.php.cn/course/572.html
In the process of developing IOS Difficulties in:
1. In swift language? and! Question
I checked a lot of helpful webpages on the Internet, but they all had different opinions and I was confused. Fortunately, one webpage made it a little clearer.
To add my personal understanding, the swift language looks simple and elegant, but in fact it contains many mysteries. Why use it? and! , the purpose is to make the code clearer and provide the compiler with more clues to find more potential errors. It is a language released by Apple, which is in line with Apple's character. It requires you to clarify things before writing code, rather than leaving vague questions to the compiler to make decisions.
2. The logic of table view
Since the iOS system is not open source, if we want to implement the table function, we must install the predetermined routines of the system. There are several key points. The first one is its two agents, one of which is responsible for providing data. The so-called providing data is the two most important interface functions. The first one tells the system how many rows there are in the table, and the second one is responsible for providing data. It just tells the system what the data in each row is. The second one will be called multiple times. Suppose there are 10 rows in a page, then this interface function will be called 10 times. But not more than one page, because the system will only request data for the page currently seen by the user. If there are 100 pieces of data in the table, then it is implemented by discarding the old data and filling in the new data during the continuous scrolling process.
This is a proxy for the view, and the other proxy is for the controller, which is what the program does when the user clicks on an item in the table. The most commonly used one here is the didSelected interface function. Developers only need to write their own implementation code here. Be careful not to write into didDeselected. The function names here are easy to confuse. Deselected is the interface called when an item changes from selected to unselected. When I first wrote this, I always felt like something was wrong, but I found out later.
When using the customer type prototype, how to access the label object inside? The use of tags.
Common table examples, the cells in the table only have a maximum of 2 labels, but I need to put 5 labels in my project, so how do I operate these labels in the code? Since the interface is pulled in IB, the labels in the cell cannot be pulled into the code through ctrl drag. Later, I saw an example of setting a tag value for each label, and then using viewByTag
UILabel *name = [cell viewWithTag:TAG_NAME]; UILabel *singer = [cell viewWithTag:TAG_SINGER]; UILabel *code = [cell viewWithTag:TAG_CODE]; UILabel *lang = [cell viewWithTag:TAG_LANG]; UILabel *type = [cell viewWithTag:TAG_TYPE];
in the code to get the corresponding label.
Later I learned by chance that it can still be accessed directly, but it is more troublesome. It is to define the cell with a class first, and then manually create the label statement in the interface. At this time, You can pull the wire from the storyboard to the table view.
This issue is discussed on this page.
Improper configuration of the table can easily cause the app to crash, and you will often see:
Crash in this place: AppDelegate: UIResponder, UIApplicationDelegate
The information displayed by debug is :
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UINavigationItem tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x7fd9d1760d70'
The reason is actually that I saw in the storyboard that the data source of the table view was not associated, so I associated the data to the table myself. Many times this kind of crash means that the associated datasource is incorrect, so you can try disconnecting it first. According to my understanding, because this bottom layer cannot be seen, I can only guess that it is associated with this one and releases the other one. As a result, the useful object cannot be found, causing the system to crash. This is why many experienced players don't like to use storyboard, because it is difficult to control and some hidden things are difficult to discover. Although it is a little more troublesome to use code to implement the interface structure, it is better than knowing enough that it will be how it is written. At this stage, I still have to rely on graphics tools. One of the disadvantages of graphics is that the storyboards of the two projects are not comparable. There were some examples where I followed the tutorial step by step, but something went wrong. But the download teacher did a good job. The project is normal, and there is no difference when comparing the codes. The difference is in the storyboard. However, the differences in the storyboard are so big that there is no clue at all. Moreover, directly overwriting the other party's files with your own is full of errors.
In general, my skills are not deep enough. In the future, we need to lay a solid foundation in depth.
3. The logic of search bar
In the past, objects such as search bar and search display were separated. Later, Apple provided an integrated solution and also integrated search The algorithms are also encapsulated into objects, which is expected to simplify the work of developers. But for developers like me, it's just the opposite. On the contrary, the simplest search bar is more suitable for me, because I only need to run a search when the content of the search bar changes, and then refresh the table once. And if you call those bundled display controllers, you need to implement more protocols, and you also need to provide a table view controller that outputs the result display, which really makes me dizzy. Apple's official information also provides an implementation example, but this example itself is very complicated and involves multiple view controllers.
The method provided on this page is more suitable for me.
This is an official example. It is an approach led by Apple. They have eliminated the old approach and now recommend the use of ui search controller. However, it is not clear what the background reason for this change is? It doesn’t feel that useful.
4. Use IB to make the interface or implement it in code?
Using code to set the size of the control may cause problems when adapting to different screens. We have not yet studied how to do the auto resize part.
But using code to create an interface is not as difficult as imagined. In fact, you only need to treat the controls in the interface as objects. Create the object, set the object's familiarity, add the object to the view, and set Set the relevant delegate, and then it's OK.
The course teacher Guo Chongzhi is young and promising, and is more in line with the tastes of young people. His lectures are relatively relaxed and natural, making us feel relaxed and more able to listen.
The above is the detailed content of Shangxuetang ios primary video material sharing. For more information, please follow other related articles on the PHP Chinese website!