views:

202

answers:

1

Hello, I want pass a number from my ViewController to the the TweetViewController. Everything worked okay, I did it with NSUInteger as property (randomNumber and tweetNumber):

TweetViewController *Second = [[TweetViewController alloc] initWithNibName:nil bundle:nil];
    Second.tweetNumber = randomNumber;
    Second.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    [self presentModalViewController:Second animated:YES];
    [Second release];

I have now changed my code because I did not want that only my TweetViewVontroller is loaded. I wanted a homescreenlike swipe between the Tweet- and InfoViewController. I use a SwitchViewController, which will be load instead of the TweetViewController. The SwitchViewController looks like this (window1/2 are UIViewController):

UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0,0,320,460)];
UIView *contentView = [[UIView alloc] initWithFrame:CGRectMake(0,0,640,460)];

self.window1 = [TweetViewController alloc];
self.window2 = [InfoViewController alloc];


[contentView addSubview:self.window1.view];

CGRect f = self.window2.view.frame;
f.origin.x = 320;
self.window2.view.frame = f;

[contentView addSubview:self.window2.view];


[scrollView addSubview:contentView];
scrollView.contentSize = contentView.frame.size;

scrollView.pagingEnabled = YES;

self.view = scrollView;

[contentView release];
[scrollView release];

Now I can´t pass the number from the FirstViewController to the TweetViewController. Any Idea, how to solve the problem?

+1  A: 
window1.tweetNumber = randomNumber;

If you want to update this every time the scrollview is scrolled, you might want to look into the UIScrollViewDelegate protocol. Specifically scrollViewWillBeginDragging:

Rengers
window1.tweetNumber doesn´t work, because he says that "request for member "tweetnumber" is something not a structure or union"
Flocked
Strange, try `[window1 setTweetNumber:randomNumber];`. While you're at it, shouldn't you init the two controllers first?
Rengers
Thanks, that works! :)I updated my code 5min ago and init the controllers ;)
Flocked