怎样点击按钮打开一个xib创建的界面
怎样点击按钮打开一个xib创建的界面或uiview
有两个xib 一个是mainwindow.xib 一个是 next.lib
[mainwindow next:oneViewController animated:YES];
这样写?
[解决办法]
#import "SwitchViewCtl.h"@implementation SwitchViewCtl-(id)init{ if (self=[super init]) { v1 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 400, 400)]; v2 = [[UIView alloc] initWithFrame:CGRectMake(0, 500, 400, 600)]; //先初始化两个View [v1 setBackgroundColor:[UIColor cyanColor]]; UIButton *bt = [[UIButton alloc] initWithFrame:CGRectMake(100, 250, 100, 50)]; [bt setImage:[UIImage imageNamed:@"114.png"] forState:UIControlStateNormal]; bt.titleLabel.text = @"显 示"; [bt addTarget:self action:@selector(openView) forControlEvents:UIControlEventTouchDown]; [v1 addSubview:bt]; [self.view addSubview:v1];//加载一个 } return self;}-(void)openView{ v1.hidden=YES;//可以先隐藏之,也可以设置Frame覆盖掉,当然还可以,从主ViewCtl中删除 [v1 removeFromSuperview]; [v2 setBackgroundColor:[UIColor blueColor]]; [self.view addSubview:v2];//加载另一个 [self.view setNeedsDisplay];//这里是刷新啦}