欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  移动技术

IOS--弹出viewController窗口 自定义底层框架--

程序员文章站 2024-01-22 11:55:04
print?//通过点击主页面按钮弹出settingpagecontroller窗口 主页面是self.view  //通过点击主页面按钮弹出settingpageco...

print?//通过点击主页面按钮弹出settingpagecontroller窗口 主页面是self.view 

//通过点击主页面按钮弹出settingpagecontroller窗口 主页面是self.view
[cpp]
//这是主页面button的点击实现函数  
-(ibaction)button_touch:(id)sender{ 
    //settingpage是一个newviewcontroller 在此进行初始化  
    settingpage*setting_page=[[settingpage alloc] initwithnibname:@"settingpage" bundle:nil]; 
    //设定settingpageviewcontroller的rootviewcontroller是uinavigationcontroller(可以任意设置)  
    uinavigationcontroller *nav = [[uinavigationcontroller alloc]initwithrootviewcontroller:setting_page]; 
    //设置leftbarbutton为完成按钮  
    uibarbuttonitem *barbutton = [[uibarbuttonitem alloc] initwithtitle:@"完成" 
                                                                  style:uibarbuttonitemstyledone 
                                                                 target:self action:@selector(achieving:)]; 
    setting_page.navigationitem.leftbarbuttonitem = barbutton; 
    nav.modalinpopover = no; 
    nav.modalpresentationstyle = uimodalpresentationformsheet; 
    [self presentmodalviewcontroller:nav animated:yes]; 
    nav.view.superview.center = cgpointmake(500, 400);//设置中点坐标  
    [setting_page.navigationcontroller.navigationbar setbackgroundimage:[uiimage imagenamed:@"toubar.png"] forbarmetrics:uibarmetricsdefault]; 
     setting_page.navigationitem.title=@"设置"; 
    [setting_page release]; 
    [barbutton release]; 
    [nav release]; 
 

//这是主页面button的点击实现函数
-(ibaction)button_touch:(id)sender{
    //settingpage是一个newviewcontroller 在此进行初始化
    settingpage*setting_page=[[settingpage alloc] initwithnibname:@"settingpage" bundle:nil];
    //设定settingpageviewcontroller的rootviewcontroller是uinavigationcontroller(可以任意设置)
    uinavigationcontroller *nav = [[uinavigationcontroller alloc]initwithrootviewcontroller:setting_page];
    //设置leftbarbutton为完成按钮
    uibarbuttonitem *barbutton = [[uibarbuttonitem alloc] initwithtitle:@"完成"
                                                                  style:uibarbuttonitemstyledone
                                                                 target:self action:@selector(achieving:)];
    setting_page.navigationitem.leftbarbuttonitem = barbutton;
    nav.modalinpopover = no;
    nav.modalpresentationstyle = uimodalpresentationformsheet;
    [self presentmodalviewcontroller:nav animated:yes];
    nav.view.superview.center = cgpointmake(500, 400);//设置中点坐标
    [setting_page.navigationcontroller.navigationbar setbackgroundimage:[uiimage imagenamed:@"toubar.png"] forbarmetrics:uibarmetricsdefault];
     setting_page.navigationitem.title=@"设置";
    [setting_page release];
    [barbutton release];
    [nav release];

}
[cpp]
//完成返回键  
-(ibaction)achieving:(id)sender{ 
    [self dismissmodalviewcontrolleranimated:yes];