Subscribe ( )

iPhone Programming Tutorials


 

Forum

You must be logged in to post Login Register

Search 

Question to tutorial “Transitioning between views”

User Post

9:42 am
August 7, 2008


Uhu

iCoder

posts 17

1

I put my question from the comment section here:


so I tried the following to get the thing to move on to different Views.

I created View1.xib, View2.xib and View3.xib

In Method UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];

I iterate the int variable i, which is declared in RootViewController.h to give me the table cell output like:
Cell 1
Cell 2
Cell 3

This works fine.

I rewrote the didSelectRowAtIndexPath method to the following, to get to different views on the individual cells, but it will always go to View3. Why? can anyone help me with that?

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Navigation logic

if (self.view2ViewController == nil) {
    if (i == 1) {
        View2ViewController *view2 = [[View2ViewController alloc] initWithNibName:@”View1″ bundle:[NSBundle mainBundle]];
        self.view2ViewController = view2;
        [view2 release];
    }
if (i == 2) {
    View2ViewController *view2 = [[View2ViewController alloc] initWithNibName:@”View2″ bundle:[NSBundle mainBundle]];
    self.view2ViewController = view2;
    [view2 release];
    }
if (i == 3) {
    View2ViewController *view2 = [[View2ViewController alloc] initWithNibName:@”View3″ bundle:[NSBundle mainBundle]];
    self.view2ViewController = view2;
    [view2 release];
    }

}
[self.navigationController pushViewController:self.view2ViewController animated: YES];
}

Kind regards. Nico

9:53 am
August 7, 2008


Admin

brandontreb

posts 88

2

Uhu,

Where is the “i” variable comming from and where is it being changed?  To get access to the indexPath variable as an integer, you need to call:

indexPath.row

This will give you the integer value of the cell that the user clicked on.

If debugging is the process of removing bugs, then programming must be the process of putting them in.
-Edsger Dijkstra

10:07 am
August 7, 2008


Uhu

iCoder

posts 17

3

thanks for your fast answer. I will check up on this things when I back at my mac at home. I am at vacation till tuesday next week.

But the indexPath.row hint is worth a million to me :)

Kind regards. Nico

10:26 am
August 7, 2008


Admin

brandontreb

posts 88

4

Yea no problem. 

If debugging is the process of removing bugs, then programming must be the process of putting them in.
-Edsger Dijkstra

7:36 am
August 8, 2008


bobcubsfan

iCoder

Los Angeles

posts 54

5

Set an integer to indexPath.Row and got an error.


NSInteger *my_index;

my_index = indexPath.Row;

Warning: assignment makes pointer from integer without a cast

7:44 am
August 8, 2008


Admin

brandontreb

posts 88

6

When declaring an NSInteger, you don't need the “*”. This is most likely the problem.

If debugging is the process of removing bugs, then programming must be the process of putting them in.
-Edsger Dijkstra

Search 

About the iCodeBlog forum

Most Users Ever Online:

44


Currently Online:

6 Guests

Forum Stats:

Groups: 2

Forums: 6

Topics: 419

Posts: 893

Membership:

There are 934 Members

There has been 1 Guest

There are 2 Admins

There is 1 Moderator

Top Posters:

bobcubsfan – 54

crazyiez – 30

Uhu – 17

AdeC – 17

Nick – 15

jitesh61 – 12

Administrators: Brandon (88 Posts), Collin (0 Posts)

Moderators: VertigoSol (26 Posts)



©   

  • Posted by on 6 Aug 2008 in Uncategorized
  •   |  
  •   |  
  •   |  
  • Comments Off

Comments are closed.