gpt4 book ai didi

ios - 如何在 Controller 的 subview Controller 中为按钮添加目标

转载 作者:行者123 更新时间:2023-11-29 03:13:49 25 4
gpt4 key购买 nike

一个有2个 Controller

@interface PlayVideoController : UIViewController

@property (strong, nonatomic) IBOutlet UIButton *playButton;@property (strong, nonatomic) IBOutlet UIButton *exportButton;- (IBAction)actionPlay:(id)发件人;和

@interface HomeController : CommonVideoViewController

在 Homecontroller 中有 2 个方法

    - (void)selectedVideoComplete:(NSDictionary *)infoVideo 
playController = [self.storyboard instantiateViewControllerWithIdentifier:@"PlayVideoController"];
// playController = [[PlayVideoController alloc]initWithNibName:@"View" bundle:nil];

// [playController.playtButton addTarget:playController action:@selector(playAction) forControlEvents:UIControlEventTouchUpInside];
playController.urlMovie = [infoVideo objectForKey:UIImagePickerControllerMediaURL];
[self.view addSubview:playController.view];
NSLog(@"_____ %@",playController.playButton);
[playController.view addSubview:btn];

- (void)playAction {
[playController.player play];
}

为什么这段代码不起作用

[playController.playtButton addTarget:playController action:@selector(playAction) forControlEvents:UIControlEventTouchUpInside];

我正在使用 Storyboard和 xib 文件进行测试

谢谢

最佳答案

目前您正在HomeController中实现playAction方法,它需要在您的PlayVideoController中实现。

或者,如果您的 playAction 方法只执行代码显示的操作,只需按如下方式设置操作:

[playController.playButton addTarget:playController.player action:@selector(play) forControlEvents:UIControlEventTouchUpInside];

希望这对您有所帮助!

关于ios - 如何在 Controller 的 subview Controller 中为按钮添加目标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21906369/

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