Gains today-Summary of programming ideas (16:46:20)

Source: Internet
Author: User
Tags call back

Today, the main task is to add printing templates for five modules. If I follow the usual thinking, I may directly create five viewcontrollers and correspond to five printing templates respectively, then, modify the XIB file to meet the requirements. However, today I have changed my mind. First, it takes a lot of time and effort to add a complex image in manual programming, and it is not conducive to intuitively adjusting the location of the UI details interface, therefore, the first attempt is to use the XIB file and drag and drop all the space to generate the file without manual addition. Second, it is also a breakthrough today. After many attempts and thoughts, I didn't use the conventional idea to create five vcpus. Instead, I directly created a printing template and tried to use the same template for these five templates, only some content in the template is modified and implemented successfully.

// Use a proxy to click different rows to enter the corresponding print template and pass the row as a parameter (here we can see that the click Time is not processed separately) if (row> = 2 | row <= 6) {[self. settingdelegate didtapprinttemplatewith: Row];} // assign the index value to the indextag (which will be used later and is an important criterion) this method initializes the template and sets the proxy event. Finally, click pushvc event-(void) didtapprinttemplatewith :( nsinteger) index {indextag = index; printtemplate * template = [[printtemplate alloc] initwithnibname: @ "printtemplate" Bundle: Nil]; self. template = template; self. template. delegate = self; [self. navigationcontroller pushviewcontroller: Template animated: Yes];}

Here I will talk about my problems in this part: At first I added the modification code of the template content between the template initialization and the push event, and the Code for modifying the result content did not achieve the expected results, instead, there is no response. After troubleshooting, I found the problem: I loaded the content modification code to the viewdidload method of the VC template, therefore, these codes have no effect (labels on all images are not loaded, and printing is null ). Then, modify it to use the delegate to call back the changetext method, provided that the template is implemented after viewdidload.

// Printtemplate. m-(void) viewdidload {[Super viewdidload]; [self. delegate changetext];} // use this method to modify the content of different templates (indextag is used as a unique judgment here)-(void) changetext {If (indextag = 2) {// purchase warehouse receiving self. template. titlelb. TEXT = @ "Purchase Order"; self. template. currentdate. TEXT = @ "14-08-26 17:29"; self. template. codno. TEXT = @ "Document No.: pu1400000001"; self. template. billdate. TEXT = @ "document date: 20140824"; self. template. supplier. TEXT = @ "supplier: Shanghai No. 1 store"; self. template. customer. hidden = yes; self. template. note. hidden = yes; self. template. totamt. TEXT = @ "Total: 1 200.00"; self. template. saler. hidden = yes; self. template. payment. TEXT = @ "Payment Method:"; self. template. cash. TEXT = @ "in cash: 0.00"; self. template. credit. TEXT = @ "swipe your card: 0.00"; self. template. account. TEXT = @ "Transfer: 0.00"; nsarray * itemsarr = @ [@ "commodity", @ "color", @ "size", @ "price", @ "quantity ", @ "sales amount"]; for (INT I = 0; I <[itemsarr count]; I ++) {[[self. template. itemstitles objectatindex: I] settext: [itemsarr objectatindex: I];} nsarray * items = @ [@ "208393", @ "blue", @ "43 ", @ "200.00", @ "1", @ "200.00"]; for (INT I = 0; I <[items count]; I ++) {[[self. template. items objectatindex: I] settext: [items objectatindex: I];} else if (indextag = 3 ){......}

 

Gains today-Summary of programming ideas (16:46:20)

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.