gpt4 book ai didi

iphone - 调用另一个 UIViewController

转载 作者:行者123 更新时间:2023-11-28 23:14:40 24 4
gpt4 key购买 nike

我在 UITableView 中,用户观看了视频。视频结束后,我希望用户进行测试。只是不知道如何调用这个 View Controller ,所以我可以开始测试。

我在 PlayListViewController 中,想调用 TestViewController

TestViewController.h 已导入。在这个阶段,TestViewController 中的所有内容都是 UIViewController 和我在 .xib 中添加的一些内容。测试编码还没有完成(那将是下一个问题)。

如果有人有时间给我指示,我将不胜感激。

-(void) movieFinishedPlaying: (NSNotification *) note {
[[NSNotificationCenter defaultCenter]
removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:[player moviePlayer]];



[player release];
NSLog(@"Video has finished playing\n");

// To the test

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Info"
message:@"Now for the test!"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles: nil];
[alert show];
[alert release];

// Call on test here
TestViewController *testVC = [[TestViewController alloc] init];
[self presentModalViewController:testVC animated:YES];
[testVC release];


}

我在 TestViewController.h 中有这个

#import <UIKit/UIKit.h>


@interface TestViewController : UIViewController {

UIWindow *tVC;
UIViewController *testVC;

}

@property (nonatomic, retain) IBOutlet UIWindow *tVC;
@property (nonatomic, retain) IBOutlet UIViewController *testVC;

@end

这在m文件中

#import "TestViewController.h"

@implementation TestViewController
@synthesize testVC, tVC;

最佳答案

在播放视频前注册 MPMoviePlayerPlaybackDidFinishNotification 通知(我猜你正在使用 MPMoviePlayerController 播放视频,对吧?):

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playerPlaybackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:playerViewController];

当它被触发时,以模态方式向他展示 TestViewController 的实例并注销通知:

- (void)playerPlaybackDidFinish:(NSNotification*)notification
{
TestViewController *testVC = [[TestViewController alloc] init];
[self presentModalViewController:testVC animated:YES];
[testVC release];
[[NSNotification defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:playerViewController];
}

关于iphone - 调用另一个 UIViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6972426/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com