开发者

Problem: Can´t pass a NSUInteger from one ViewController to the other anymore

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 n开发者_StackOverflowot 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?


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:

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜