Telerik Software Academy Mobile apps for iPhone & iPad
iOS app architecture ViewControllers Views Linking Views to ViewControllers Adding and Using Controls
Templates and Stuff
iOS apps are build from two components: Views – represent the UI ViewControllers – the programming logic Views are linked to ViewControllers ViewControllers are regular classes They can fetch data from the views They can send data to the views They can change the views programatically
Views and Controls
Views are represented by a XIB (NIB) files They hold the UI components Can contain UI logic Is built from controls When creating an iOS app, a initial view is created Depending on the project type it can be empty or with a scaffold application
To add controls to a View: Open a storyboard file (Main.storyboard) Show the Utilities Drag a control from the toolbox into the view
Live Demo
UIViewController and UITableViewController
ViewControllers are the code-behind of a View They are linked to a View Can react to events from a View (button click, text change, etc…) Can send data to a View Change the content of a text field, take the selected date from a DatePicker, etc… Can change a View Create animations or replace views
There are many types of ViewControllers UIViewCotroller, UITableViewController, UISplitViewController, etc.. UIViewController and UITableViewController are used the most UIViewController is a generic ViewController Nothing special about it UiTableViewController is used for a table view Used to list data
To create a UIViewController: Create a regular class and inherit UIViewController Select a view from a storyboard In the Utilities Show Identity Inspector Type the name of your UIViewController into the class text field Done, can link controls
Live Demo
UITableViewController is done pretty much the same as UIViewController Inherit UITableViewController, instead of UIViewController UITableViewController needs a little setup Create a Table View to the storyboard Add a table view cell to the table view Give it an identifier Write two methods in your TableViewController -tableView:cellForRowAtIndexPath-tableView:numberOfRowsInSection
Live Demo
To link (use) controls in the ViewController, IBOutlets must be created Go to the Storyboard CTRL + click on the control Select "New Referencing Outlet" and drag it to the ViewController A property is created so the control can be used in the ViewController
Live Demo
With a IBOutlet, a control can be used in the ViewController Yet actions are hard to be handled We can link an event from a control from the View to a method in the ViewController CTRL + click on the control Select a event (i.e. "Touch up inside") and drag it to the linked ViewController
Live Demo
форум програмиране, форум уеб дизайн курсове и уроци по програмиране, уеб дизайн – безплатно програмиране за деца – безплатни курсове и уроци безплатен SEO курс - оптимизация за търсачки уроци по уеб дизайн, HTML, CSS, JavaScript, Photoshop уроци по програмиране и уеб дизайн за ученици ASP.NET MVC курс – HTML, SQL, C#,.NET, ASP.NET MVC безплатен курс "Разработка на софтуер в cloud среда" BG Coder - онлайн състезателна система - online judge курсове и уроци по програмиране, книги – безплатно от Наков безплатен курс "Качествен програмен код" алго академия – състезателно програмиране, състезания ASP.NET курс - уеб програмиране, бази данни, C#,.NET, ASP.NET курсове и уроци по програмиране – Телерик академия курс мобилни приложения с iPhone, Android, WP7, PhoneGap free C# book, безплатна книга C#, книга Java, книга C# Николай Костов - блог за програмиране
Create a UITableViewController that holds a list of generated and encoded passwords Each password has an account name and encryption code Once you type the code, the encrypted password is decrypted Implement a UIViewController for adding a password, encryption code and an option to create a random password