我对 iOS 开发完全陌生,我想在当前视图中按下按钮时加载另一个视图。
我创建了一个基于视图的应用程序,以下是代码:
//我的文件名为poo1
//这是poo1ViewController.h文件
#import <UIKit/UIKit.h>
@interface poo1ViewController : UIViewController
{
IBOutlet UIButton *fl;
}
@property (nonatomic,retain) UIButton *fl;
-(IBAction) ifl:(id)sender;
@end
//这是poo1ViewController.m文件
#import "poo1ViewController.h"
@implementation poo1ViewController
@synthesize fl;
-(IBAction) ifl:(id) sender {
}
In the poo1ViewController.xib
我添加了一个按钮并使用 Interface Builder 将其与文件所有者链接。
现在我向此类添加了另一个视图,称为flip.xib
刚刚在其中添加了一个标签。
我想要的是,当我按下fl
按钮,fl
按钮将调用该方法ifl
作为回报,应该调用第二个视图,即flip.xib
.
我将如何做到这一点,我怎样才能使ifl
加载方法flip.xib
view ?
UIViewController* flipViewController = [[UIViewController alloc] initWithNibName:@"flip.xib" bundle:[NSBundle mainBundle]];
[self.view addSubview:flipViewController.view];
EDIT:
UIViewController* flipViewController = [[UIViewController alloc] initWithNibName:@"flip" bundle:[NSBundle mainBundle]];
[self.view addSubview:flipViewController.view];
现在单击flip.xib,单击设计区域左侧的File's Owner,并将类更改为UIViewController。现在按住 CTRL 键从“文件所有者”图标拖动到其正下方的“视图”图标,然后选择 IBOutlet 视图。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)