iOS Research iOS Development Notes Basics Learning

Source: Internet
Author: User

This article is my iOS learning note, both of which are basic knowledge points, which are documented here later in the query.

1,uiscrollview View class to complete the scrolling function. examples are as follows:Uiscrollview *tablescrollview;Tablescrollview=[[uiscrollview alloc] Initwithframe:cgrectmake (0, 0, 320, 480)];//window sizeTablescrollview.contentsize=cgsizemake (640, 480);//Set the size of the content viewTablescrollview.showsverticalscrollindicator=no;Tablescrollview.showshorizontalscrollindicator=no;tablescrollview.delegate=self;Tablescrollview.bounces=no;Tablescrollview.pagingenabled=yes;[Self.view Insertsubview:tablescrollview Belowsubview:navigationbarview];//Insert Tablescrollview view below the Navigationbarview view of this class(void) Scrollviewdidscroll: (Uiscrollview *) scrollview;//scrolling operation is occurring(void) scrollviewdidenddecelerating: (Uiscrollview *) scrollview;//Swipe end Operation
2, nsthread Multithreading Reference Technology blog is very good very strong you can see. [Nsthread detachnewthreadselector: @selector (function name) totarget:self withobject: parameter (needs to be an object)];Example:[Nsthread detachnewthreadselector: @selector (getpopularitydata:) totarget:self Withobject:[nsnumber Numberwithint:1]];
3, Create a new class that completely obeys the parent classMessageView.h#import <UIKit/UIKit.h>#import "RefreshTableView.h"@interface Messageview:refreshtableview@endmessageview.m#import "MessageView.h"@implementation Messageview@endthen the header and implementation files for this class are simple.
4 , the parent Class View initialization problemIn the view class ground-(void) Viewdidload function, the following statement should be executed at the very beginning:[Super Viewdidload];the statement executes its parent-class Viewdidload method, which helps us to do some initialization work. Otherwise, an error may occur when we invoke some methods.
5, Message Notification NsnotificationcenterPurpose: Nsnotificationcenter is set up specifically for communication between non-homogeneous messages in the program. Registration Notice:[[Nsnotificationcenter defaultcenter] addobserver:self selector: @selector (mytest:) name:@ "MyTest" object:nil];parameter Description:Addobserver: The Observer, where the notice is received;Selector: What method to call after receiving notification;Name : The notification is named, and is the only indication of the notification, the compiler will find the notification through this.
Send notification: Invokes the method at the Observer. [[Nsnotificationcenter Defaultcenter] postnotificationname:@ "mytest" Object:searchfriendarray];parameter Description:Postnotificationname: The name of the notification, is also the only indication of the notification, the compiler to find the notification through this. object: Passed parameters
[2013.5.15] Added: Nsnotificationcenter use method with parameters:Parameters are generally not used when using nsnotificationcenter, but sometimes it is necessary to use parameters. Passing parameters, where the example passes an array tekubaarray:[[nsnotificationcenter defaultcenter] postnotificationname:@ "Tekubadata" object: Tekubaarray]; receive parameters and get passed arguments[[Nsnotificationcenter defaultcenter] addobserver:self selector: @selector (Tekubatestname:@ "Tekubadata[Object:nil];Postnotificationname: The name of the notification, is also the only indication of the notification, the compiler to find the notification through this. Object: Passed parameters -(void) Tekubatest: (nsnotification*) Notification{nsmutablearray* DataArray = [notification object];//through this gets to the passed object}6, attribute list Nsuserdefaultswhen the amount of data stored is small, you can use multiple rows of key-value to save and read data. Example:get information on Cuseridnsstring *usernameid=[[nsuserdefaults standarduserdefaults] valueforkey:@ "Cuserid"];Save a Knumberlocationkey key of numberlocation with a value of 123456. nsstring *knumberlocationkey = @ "Numberlocation";nsstring *savenumber = @ "123456″;[[Nsuserdefaults standarduserdefaults] Setobject:savenumber Forkey:knumberlocationkey];
7, multiple parameter issues in iOS programming-(void) Createstreamer: (UIView *) View urlstring: (NSString *) urlstring{}The parameters are view, and urlstring, respectively.
8, use of the Nstimer timerNstimer is actually a listener to join the system Runloop, when the system Runloop to how the timer condition loop, will call the timer once, when the timer executes, that is, after the callback function execution, The timer will once again add itself to the Runloop to continue listening. Example:[Nstimerscheduledtimerwithtimeinterval:1target:selfselector: @selector (updateprogress:)Userinfo:viewRepeats:yes];parameter Description:scheduledtimerwithtimeinterval: (nstimeinterval) secondsBook a timer and set a time interval. The implied input is a time interval object, in seconds, a value of a >0 floating-point type, if the value <0, the system defaults to 0.1target: (ID) atargetimplicitly sent objects, such as selfor: (SEL) Aselectormethod Selector, within the time interval, choose to invoke an instance methodUserInfo: (ID) userInfoThis parameter can be considered nil, and when the timer fails, the timer is saved and released by the object you specify. repeats: (BOOL) YesornoWhen Yes, the timer will renew the cycle until it expires or be released, and when no, the timer will be sent once in a cycle to fail. Invocation: (nsinvocation *) Invocation
9, Xcode Output Window prints nsdata dataNSData *tempdata;//assumes TempData has populated the dataNSLog (@ "\n%@\n", [[NSString alloc] Initwithdata:tempdata encoding:nsutf8stringencoding]);//print data to get data, The strings in TempData are printed correctly after testing. of course, you can also use NSLog (@ "\n%@\n", tempdata);//Direct printing, test the results of printing 16 of the form of paper feed

iOS Research iOS Development Notes Basics Learning

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.