Tuesday, February 3, 2009
iPhone Development: Application Preferences Part 2
iPhone Development: Application Preferences
- PSTitleValueSpecifier: Used to write titles, similar to UILabel
- PSTextFieldSpecifier: Similar to UITextField
- PSToggleSwitchSpecifier: A toggle switch which can be ON or OFF
- PSSliderSpecifier: A slider which can be used to provide a value bw MAX and MIN
- PSMultiValueSpecifier: Shows multiple values from which user can select one.
- PSGroupSpecifier: Very important for layout (discussed later).
- PSChildPaneSpecifier: When you need to have another page of configurations.
- Using PSChildPaneSpecifier and adding rest of the types.
- Accessing application preferences from inside your code
- Changing preferences from your code.
Tuesday, January 20, 2009
iPhone Development: Navigating from 1 view to other

In this post I will be making another view and tell you how to navigate from first view to the one we are going to create now. Please refer my previous post as I am going to add code to the same project.
aTableView.delegate = self;
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if (cell == nil) {
So what is this dequeReusableCell? Why can't we just create a cell by alloc and init? We can do that but there is something you should always keep in mind. This method is called every time you scroll the tableView and a new cell which was not visible earlier gets visible. Imagine you have 20 cells in the table and iPhone can display only 19 on full screen. So the 20th cell will be created by cellForRow method only when it gets visible on the screen. But then the first cell will go out of view ryt? When you scroll back to view the first screen, cellForRow method will be called again to to return a cell to be displayed at first place. That's why we use dequeReusablelCell so that it doesn create a new cell every time.
CAUTION: Do not do anything stupid inside cellForRow method cuz it gets called multiple times.
Finally we have created the view and are ready to use it. What we want is that the new view should appear when we click the "Hit Me" button we created earlier.
So open MyTestProjectViewController.h and modify it to look like this:
We have only defined an instance of MyTableView here, to create it and push it on button click
open MyTestProjectViewControler.m and modify buttonPressed method we created earlier to look like this:
Here we are creating an instance of MyTableView and pushing it over the view which we are looking at now.
If you build this project and run it, you will see the same screen as we saw last time, on pressing the button you will notice that nothing happens. If you chose "navigation based" template when creating the project last time this code would have worked, but since we chose "view based" template its not working. This is the reason why I picked this template so that we can learn how we can programatically do any this we want.
The reason why the new view is not getting pushed is that there is no navigationController attached to the originalView. To do so open MyTestProjectAppDelegate.m and find a method named - (void)applicationDidFinishLaunching:(UIApplication *)application
Add the code to make it look like this
iPhone Development: Creating a Simple View
-(void)buttonPressed
{
NSLog(@"button was pressed");
iPhone Development: Customizing HeaderView

This post will discuss how we can add a headerView to a UITableView and customize it.



















