IPhone Enterprise Application Example 3: Program Framework Analysis

Source: Internet
Author: User

IPhone Enterprise Application Example 3: Program Framework Analysis

The webdoc mobile Project is a typical multi-layer process system. Therefore, the system mainly uses uinavigation controller to navigate the user interface, so that when the user enters the next interface from the previous interface, after the next page is processed, you can easily return to the previous page. After you log on to the system, the system displays the main menu, as shown in Figure 5-6.
The main menu is divided into four options: "My documents", "department documents", "Advanced Search", and "statistical charts". The main menu is implemented in the mainviewcontroller class, this class uses uitableview to manage menu items. The uitableview data source uses an nsmutablearray to provide table data. When creating a table, use the following command.
-(Nsinteger) tableview :( uitableview *) tableview numberofrowsinsection: (nsinteger) Section {

 

Return menulist. count;
}

-(Uitableviewcell *) tableview :( uitableview *) tableview cellforrowatindexpath: (nsindexpath *) indexpath {
Nsdictionary * datadictionary = [menulist objectatindex: indexpath. Row];
Cell. textlabel. Text = [datadictionary valueforkey: ktitlekey];
Return cell;
}
Returns the number of rows in the table and the specific content of each row. Table data in each row contains the title and Class Name of the next layer of the viewcontroller interface. When you click the menu item in the main menu, the program uses this class name to call nsclassfromstring () to create a class object, then creates a viewcontroller object, and adds viewcontroller to uinavigation controller for interface display.
-(Void) tableview :( uitableview *) tableview didselectrowatindexpath: (nsindexpath *) indexpath {
Targetviewcontroller = [[nsclassfromstring (viewcontrollername) alloc] initwithnibname: viewcontrollername Bundle: Nil];
[Self. navigationcontroller pushviewcontroller: targetviewcontroller animated: Yes];
}
After you select "My Documents" or select a specific department on the "department documentation" page, and use the "Document Search" function to search for a document, the program displays the document list, as shown in Figure 5-7.
 


The document list is displayed using the doclistviewcontroller class. This class includes the document record pagination and navigation functions. When the maximum number of records per page is exceeded, you can use the forward and backward arrows to flip pages. In addition, after the user searches, the program also uses this class to display the search results.
The doclistviewcontroller class contains a uitableview member variable. The program uses this table to display the document list. The table data source uses an nsmutablearray to store and provide data. Each element of this array is a documentdetailviewcontroller class instance, create these documentdetailviewcontroller class instances by traversing the file list.
For (I = 0; I <nresult; I ++ ){
Documentdetailviewcontroller * presidentsviewcontroller =
[[Nsclassfromstring (viewcontrollername) alloc]
Initwithnibname: viewcontrollername Bundle: Nil];
Document * Doc = [Objects objectatindex: I];
Presidentsviewcontroller. Title = doc.doc umentname;
[Presidentsviewcontroller setdocument: Doc];
[Controllers addobject: presidentsviewcontroller];
[Presidentsviewcontroller release];
}
When you click a document in the document list, the program extracts the corresponding elements from the array and displays the documentdetailviewcontroller object.
-(Void) tableview :( uitableview *) tableview
Didselectrowatindexpath :( nsindexpath *) indexpath {
[Tableview deselectrowatindexpath: indexpath animated: Yes];
Nsuinteger ROW = [indexpath row];
If (self. controllers! = Nil ){
Documentdetailviewcontroller * nextcontroller = [self. Controllers
Objectatindex: Row];
// Preload detail, attachment and history.
[Nextcontroller preloaddata];

// Clear Cache
[Self handlewithcache];
 
// Push document Detail view...
[Self. navigationcontroller pushviewcontroller: nextcontroller animated: Yes];
}
}
Because the documentdetailviewcontroller class requires a large amount of content, the program uses pagination to organize the content, the documentdetailviewcontroller class uses a uisegmentedcontrol class to manage four specific pages: document details, document attachments, document history, and workflow, as shown in Figure 5-8.
In this way, when you enter the document details page, you can easily switch between the document attachments, document history, and other pages. In the viewdidload () method of the documentdetailviewcontroller class, you can use addtarget () the function sets the response function when the uisegmentedcontrol page is switched. This response function is set when the uisegmentedcontrol object is created. The didchangesegmentcontrol function is set here.
Self. segmentedcontrol = [[uisegmentedcontrol alloc] initwithitems: segmenttitles];
[Self. segmentedcontrol addtarget: Self
Action: @ selector (didchangesegmentcontrol :)
Forcontrolevents: uicontroleventvaluechanged];
When a user switches between pages, this function is called. The function first removes the current active page and then activates and displays the page selected by the user.
 


-(Void) didchangesegmentcontrol :( uisegmentedcontrol *) control {
If (self. activeviewcontroller ){
[Self. activeviewcontroller viewwilldisappear: No];
[Self. activeviewcontroller. View removefromsuperview];
[Self. activeviewcontroller viewdiddisappear: No];
}

Self. activeviewcontroller = [self. segmentedviewcontrollers objectatindex: Control. selectedsegmentindex];
[Self. activeviewcontroller viewwillappear: Yes];
[Self. View addsubview: Self. activeviewcontroller. View];
[Self. activeviewcontroller viewdidappear: No];

}
This enables switching, hiding, and displaying between four pages. The documentdetailview controller class uses the uisegmentedcontrol class to organize the page content, which is the main body of the program and the focus of programming. This class organizes and manages the page content through the other four classes, the other four categories are the docdetailview controller class, which is used to display document details; docfilesviewcontroller class, which is used to manage document attachments; dochistoryviewcontroller class, which is used to manage document change history; docworkflowviewcontroller class, which implements workflow management.
When you click the "Department document" main menu, the program displays the Department List page, as shown in Figure 5-9.
When you select a specific department, the program queries the backend database of the server through the Web service, and then displays the data returned by the server, that is, the list of documents currently processed by the selected department is displayed.
When you select the "Statistical Chart" main menu, the program lists the existing statistical charts of the system, as shown in 5-10.
When you click the statistical chart details icon, the program queries the server background database through the Web service, and displays the Statistical Chart on the mobile phone based on the returned data, as shown in Figure 5-11.


This article is excerpted from the book IOS software development secrets: iPhone & iPad enterprise applications and game development.
The book IOS software development secrets: iPhone & iPad enterprise application and game development has been officially published by the Electronics Industry Publishing House, and this book is published by Yu Bin.

Purchase address:

Dangdang:
Http://product.dangdang.com/product.aspx? Product_id = 21082051

Zhuo yuewang:
Http://www.amazon.cn/iOS%E8%BD%AF%E4%BB%B6%E5%BC%80%E5%8F%91%E6%8F%AD%E5%AF%86-iPhone-iPad%E4%BC%81%E4%B8%9A%E5%BA%94%E7%94%A8%E5%92%8C%E6%B8%B8%E6%88%8F%E5%BC%80%E5%8F%91-%E8%99%9E%E6%96%8C/dp/B0051HAIA4/ref=sr_1_1? S = books & Ie = utf8 & qid = 1306139777 & sr = 1-1

Interactive publishing network: http://product.china-pub.com/198191

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.