问题:不能再将NSUInteger从一个ViewController传递给另一个

时间:2010-01-04 12:39:56

标签: iphone objective-c xcode

我想从我的ViewController传递一个数字到TweetViewController。一切正常,我用NSUInteger做了属性(randomNumber和tweetNumber):

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

我现在已经更改了我的代码,因为我不想只加载我的TweetViewVontroller。我想在Tweet-和InfoViewController之间进行类似主屏的滑动。我使用SwitchViewController,它将加载而不是TweetViewController。 SwitchViewController看起来像这样(window1 / 2是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];

现在我无法将FirstViewController中的数字传递给TweetViewController。任何想法,如何解决问题?

1 个答案:

答案 0 :(得分:1)

window1.tweetNumber = randomNumber;

如果要在每次滚动滚动视图时更新此内容,您可能需要查看UIScrollViewDelegate协议。具体来说是scrollViewWillBeginDragging: