欢迎访问移动开发之家(rcyd.net),关注移动开发教程。移动开发之家  移动开发问答|  每日更新
页面位置 : > > > 内容正文

点击任何处,弹出另外一个界面(出行搭档),出行搭档

来源: 开发者 投稿于  被查看 14917 次 评论:226

点击任何处,弹出另外一个界面(出行搭档),出行搭档


 

点击任何处的效果图:

文件目录:

MoreView.h

#import <UIKit/UIKit.h>

@interface MoreView : UIView

@end

 

MoreView.m

#import "MoreView.h"

@implementation MoreView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        
        //设计背景色为红色
        self.backgroundColor=[UIColor redColor];
    }
    return self;
}

 

RootViewController.h

#import <UIKit/UIKit.h>
//头文件
#import "MoreView.h"

@interface RootViewController : UIViewController
{
    //是否点击
    BOOL isSwitch;
    //红色UIView界面
    MoreView *moreView;
}
@end

 

RootViewController.m

 

//点击任何处,显示出红色的UIView
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    if (isSwitch) {
        [moreView removeFromSuperview];
        isSwitch=NO;
    }else{
        moreView=[[MoreView alloc]initWithFrame:CGRectMake(10, 100, 200, 50)];
        [self.view addSubview:moreView];
        isSwitch=YES;
    }
   
}

 


MFC中点击一个界面的某个按钮就会弹出另外一个界面详细步骤

void CDlg1::OnButton1()
{
CDlg2 dlg2;
dlg2.DoModal();
}
 

网站主页是怎实现点击后弹出另外一个页面?

_blank 弹出新页面
_self 在原窗口打开
 

用户评论