Jump to content

iPhone SDK - Interface Builder Tutorial


115 posts in this topic

Recommended Posts

Hi,

i have a View which is composed of a sample image(*.png) as well as a Table view (with 3 sections). Table view is below the image. (All these are done in the code,not with the IB.)

When i load this screen,since i have more data on the table view,some part of the table view goes done and not visible in the inital launch. Here i would like to scroll down (by pressing the screen down) to see the rest of the data. But this is not working for me.

If i have only the table view , scrolling down works fine ( since that is the scroll on the table view). But if i have the image as well on the View, scrolling down in not working.

 

can any pls tell me how to enable the scroll at the view level. i am missing something here.

thanks.

Link to comment
Share on other sites

Okay I did that and it works... but... here's the new wrinkle...

 

As part of TableView we have a default method of:

 

"- (void)tableView:(UITableView *)tableView accessoryButtonClickedForRowWithIndexPath:(NSIndexPath *)indexPath"

 

(but I can't seem to get it to trigger - so I used the solution you suggested)

 

In the solution you presented I have the (two) following lines:

 

cell.accessoryAction = @selector(myCustomAction); // Including a : at the end didn't work!!

cell.target = self;

 

{SNIP the rest of my babbling}

 

======================================================================

***EDIT***

 

Okay I finally got things going CORRECTLY and to the best of my knowledge the way they should be...

 

Here was my initial downfall:

 

"- (void)tableView:(UITableView *)tableView accessoryButtonClickedForRowWithIndexPath:(NSIndexPath *)indexPath"

 

I was using this method --- well because I found it somewhere --- I know I didn't make it up... :D (maybe it was changed from the initial SDK??) I dunno but that is the method that I thought I needed to implement.

 

***WRONG***

 

Simply reading the headers for UITableView I instead I saw this method referneced:

 

- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath

 

I took out the overrides I was trying get working (in otherwords I deleted these new lines that I was speaking about above)

 

cell.accessoryAction = @selector(myCustomAction); // Including a : at the end didn't work!!

cell.target = self;

 

Then I renamed accessoryButtonClickedForRowWithIndexPath to accessoryButtonTappedForRowWithIndexPath...

 

Compiled and all is now good with my world (for a little while anyway) :)

 

Thanks again for everyones help.

 

Dave

 

MAHAHA I got it now (I was silently watching this thread :))

Thanks, I was missing the cell.target = self

SDK DOCS SUCK BTW...

Link to comment
Share on other sites

Hi,

 

I am building my app with pure code. Not using IB.

 

i need to have the tap (touching and moving the finger on the view) and flip ( turn back )functionality together in my application.

Means, i have an application which has totally three screens / views. No navigation,No tab bar. Straight simple views.

 

Upon Tap (touching and moving the finger on the view,from right to left) the first screen, i want the second screen to come from the side. If do the same thing on the second screen,third screen should come from right side , 2nd screen goes out thru left side.

 

I need one more functionality on each of these screens. I will have a button on each of the views,on clicking that button,the view will flip ( turn back) and show the different content.

 

These functionalities are pretty similar to the ones in iPhone Weather application.

 

I am able to do these two functionalities separately in two projects ( flip in one and tap in other project). But when i am trying to have it in the same application,its not working.

Can some one guide with some steps to be followed in getting these features done.

 

 

thanks in advance.

mp

Link to comment
Share on other sites

Hi,

 

I am building my app with pure code. Not using IB.

 

i need to have the tap (touching and moving the finger on the view) and flip ( turn back )functionality together in my application.

Means, i have an application which has totally three screens / views. No navigation,No tab bar. Straight simple views.

 

Upon Tap (touching and moving the finger on the view,from right to left) the first screen, i want the second screen to come from the side. If do the same thing on the second screen,third screen should come from right side , 2nd screen goes out thru left side.

 

I need one more functionality on each of these screens. I will have a button on each of the views,on clicking that button,the view will flip ( turn back) and show the different content.

 

These functionalities are pretty similar to the ones in iPhone Weather application.

 

I am able to do these two functionalities separately in two projects ( flip in one and tap in other project). But when i am trying to have it in the same application,its not working.

Can some one guide with some steps to be followed in getting these features done.

thanks in advance.

mp

 

 

Look at UIPageControl and setting the pagingEnabled: property of UIScrollView, that should get you started, since flipping between views is already standardized. I don't know exactly how to implement, but if I figure out how, I'll let you know.

Link to comment
Share on other sites

First of all, thanks for all the help and pointers so far. I have been lurking for quite a bit and finally decided to jump in.....

 

I am probably being a little dense here but I have a question about the following example:

1. Add a UINavigationController in IB

2. Add 2 UIViewControllers each with 1 UINavigationItem. Be sure to set titles for your UIViewControllers

3. Add an outlet to your UINavigationController called myRootViewController

4. Connect the outlet to one of the UIViewControllers you just make

5. Add an outlet to the UIViewController you just linked to your UINavigationController called childViewController

6. Connect the outlet to the second UIViewController

7. Write out class files for the UINavigationController and the first UIViewController

8. After unmucking the class files that IB makes add to the UINavigationController a - (void)awakeFromNib method with the following line:

[self initWithRootViewController:myRootViewController];

9. To display your nav controller call [window addSubview:navViewController.view]; from your main AppDelegate

10.To load a second view into the nav controller with the fancy slide effect add a button to the first UIViewController with the following line:

[[self navigationController] pushViewController:childViewController animated:YES];

 

In step 9 is the navViewController supposed to be the name of the UINavigationController in step 1? Weather or not it is I get:

error: 'myNavController' undeclared (first use in this function)
(I called mine myNavController)

 

I have already done all of this in code but it looks like IB is the way to go so rather than keep moving on in code I am trying to switch. Based on other posts I am not looking forward to trying to get Nav Controllers and Tabbar controllers working together.

Link to comment
Share on other sites

  • 4 weeks later...

Yeah, this is definitely not cool with Beta 5. It throws in a MainWindow.xib that automatically starts up (I'm assuming it knows from the stuff in Info.plist), so I'm currently attempting a tactic where I put a UIView inside that .xib as the first view shown. It works pretty well, but I now have no idea how I can transition into another view when I hit a button on that page, since the call to that occurs within that view. Any help out there?

Link to comment
Share on other sites

  • 2 weeks later...

Jordan Kay:

 

The problem is a typo (missing line, really) in the tutorial: at the end of the subview initialization, Apple forgot to show the new view.

 

To fix it, add the following to the end of the applicationDidFinishLaunching method of HelloWorldAppDelegate.m:

 

[window makeKeyAndVisible];

Link to comment
Share on other sites

  • 2 weeks later...

Hello,

 

I'm brand new to Iphone programming and I'm very lost. To begin with, I'm just trying to make a set of lists as comparable as using the mail button on the current Iphone.

 

For example:

 

 

 

<Back]

--------------------------

happy ---->

--------------------------

sad

--------------------------

tired

--------------------------

lonely

--------------------------

angry

--------------------------

etc.

--------------------------

etc.

--------------------------

 

 

 

 

<Back]

--------------------------

weddings ---->

--------------------------

birthdays

--------------------------

anniversaries

--------------------------

having a child

--------------------------

 

 

 

 

<Back]

--------------------------

how to prepare

--------------------------

finding a midwife

--------------------------

taking care of a newborn

--------------------------

 

 

 

Any insight on the code structure for something generic like this would be super helpful!

 

Thanks!

Link to comment
Share on other sites

uprise78, your code example looks like just what I am trying to figure out. I want to slide from one view to another. However I am totally new to iPhone dev and have been trying to understand where each of these pieces of code belongs. Are there some more specific details, or better yet an example app that shows just this?

 

Where does

[window addSubview:viewController.view]

go? In the AppDelegate? In applicationDidFinishLaunching? Do I put both viewController and viewController2 there?

 

Where do I put

[window insertSubview:newView atIndex:index];
CATransition *animation = [CATransition animation];
[animation setDelegate:self];
[animation setType:kCATransitionFade];
[animation setDuration:0.75];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[[window layer] addAnimation:animation forKey:@"SomeKeyName"];

and then how do I call this? Does it go into viewController? If so how does it know about window? Where does index come from? Or does it go in AppDelegate and I call that from viewController?

 

Thanks!

 

So, I used IB to wire up two view controllers (named viewController and viewController2) each with one view and each view having one button. I used
[window addSubview:viewController.view]

to add the view to the window and display it. You'll have to add the Quartz framework to your project and then put <QuartzCore/QuartzCore.h> in the header file to get the core animation classes. From there its pretty simple to get things animated. The code below will use a fade transition and an EaseInOut transition type but it is trivial to use any of the others once you get this working. Insert a new view and get the animation going with

[window insertSubview:newView atIndex:index];
CATransition *animation = [CATransition animation];
[animation setDelegate:self];
[animation setType:kCATransitionFade];
[animation setDuration:0.75];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[[window layer] addAnimation:animation forKey:@"SomeKeyName"];

 

That should get you going with your view animations.

Link to comment
Share on other sites

  • 2 months later...

I downloaded the example -- and it worked

 

THen I went into IB, added a rounded button and saved the xib file. (Didn't even TRY to make connections, etc)

 

When I hit build and go, the app crashes

 

What gives?

 

THanks!

 

rwc

Link to comment
Share on other sites

  • 2 weeks later...
 Share

×
×
  • Create New...