当前位置:编程学习 > wap >>

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

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]; 

补充:移动开发 , IOS ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,