Knowledge of IOS nooks and crannies

Source: Internet
Author: User
Tags border color notification center
<span id="Label3"></p><p><p><span style="color: #aa7942;">1. Global Variables</span></p></p><p><p>static Nsinteger Kimageheight = 300;</p></p><p><p>#define Kimageheight 300</p></p><p><p><span style="color: #aa7942;">2. Notification Center</span></p></p><p><p><span style="color: #aa7942;">Start editing</span></p></p><p><p>Uitextviewtextdidbegineditingnotification</p></p><p><p><span style="color: #aa7942;">is changing</span></p></p><p><p>Uitextviewtextdidchangenotification</p></p><p><p><span style="color: #aa7942;">End compilation</span></p></p><p><p>Uitextviewtextdidendeditingnotification</p></p><p><p></p></p><p><p>Registration text Change Notification</p></p><p><p></p></p><p><p>[[nsnotificationcenter defaultcenter] addobserver:self selector: @selector (textdidchangenotifition:) name: Uitextviewtextdidchangenotification object:nil];</p></p><p><p>-(void) Dealloc</p></p><p><p>{</p></p><p><p>[[nsnotificationcenter defaultcenter] removeobserver:self name:uitextviewtextdidchangenotification object:nil];</p></p><p><p></p></p><p><p>}</p></p><p><p></p></p><p><p><span style="color: #aa7942;">3. Dynamic loading (without Importing header files)</span></p></p><p><p><span style="color: #aa7942;"></span></p></p><p><p>Nsarray * vcNames1 = @[@ "friendviewcontroller"];</p></p><p><p>Nsarray * VcNames2 = @[@ "swipeviewcontroller", @ "sharkviewcontroller"];</p></p><p><p></p></p><p><p>Self.viewcontrollers = @[vcnames1,vcnames2];</p></p><p><p>NSString * Vcname = self.viewcontrollers[indexpath.section][indexpath.row];</p></p><p><p></p></p><p><p>Uiviewcontroller * VC = [[nsclassfromstring (vcname) alloc] init];</p></p><p><p>Example: Custom button Class: UIButton</p></p><p><p>The Viewcontroller claims that the corresponding button object is overridden by the Init method to define the type</p></p><p><p>The Button property cannot be written in the Button class because adding a click event to the lazy load cannot be adjusted</p></p><p><p><span style="color: #aa7942;">4. Change the color of the picture; ignore its color information</span></p></p><p><p>Image = [image imagewithrenderingmode:uiimagerenderingmodealwaystemplate];</p></p><p><p></p></p><p><p><span style="color: #aa7942;">5. Project Structure</span></p></p><p><p></p></p><p><p><span style="color: #aa7942;">6, when the Navigation view controller presses the stack, hides the Tabbar</span></p></p><p><p>vc.hidesbottombarwhenpushed = YES;</p></p><p><p><span style="color: #aa7942;">7, Picture and border, code:</span></p></p><pre name="code"><pre name="code">Imagelayer.bordercolor = [uicolor graycolor]. cgcolor; Border color imagelayer.borderwidth = 2.0; Border width</pre></pre><pre name="code"><pre name="code"><span style="color: #aa7942;">8, Lei God teaching block</span></pre></pre><p><p>(1) declaring the block variable and setting the return value type</p></p><p><p>typedef nsstring * (^myblock) (nsstring *);</p></p><p><p>@property (nonatomic, copy) Myblock block;</p></p><p><p>(2) Call the Block method (send) and receive the return value</p></p><p><p>NSString * string = Self.block (@ "123<span style="font-family: Menlo;">"</span>);</p></p><p><p>NSLog (<span style="font-family: Menlo;">@ "%@"</span>, string);</p></p><p><p><span style="font-family: Menlo;">(3)</span> Call The Block method (receive) and receive the return value</p></p><p><p>Self.ceshi.block = ^ (nsstring *string) {</p></p><p><p></p></p><p><p>NSLog (@ "%@", string);</p></p><p><p></p></p><p><p>return<span style="color: #35568a;"><span style="font-family: Menlo;"><span style="font-size: large;">@ "peng"</span></span></span><span style="font-family: Menlo;">;</span></p></p><p><p>};</p></p><p><p>(4) use typedef to define block types (much like pointers to Functions)</p></p><p><p>(class) Typedef int (^myblock) (int, int);</p></p><p><p>You can then use this type to define the block Variable.</p></p><p><p>(class) Myblock block1,block2;</p></p><p><p>(class) int i = Block1 (3,4);</p></p><p><p>(master) block1=^ (int a,int b) {</p></p><p><p>Return a-b;</p></p><p><p>};</p></p><p><p>__weak Viewcontroller *myself = self; Avoid circular references in block</p></p><p><p></p></p><p><p>Knowledge of IOS nooks and crannies</p></p></span>

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.