JGCX 文件 是哪个通讯通信工程预算软件件

1260人阅读
我是新手(7)
*我们都知道,iOS7导航控制器默认自带了侧滑功能,当用户在界面的左边滑动的时候,就会有侧滑功能。
但是如果我们从从导航控制器的返回按钮,就发现系统所带的侧滑返回功能无法使用。因此为了解决此问题,有以下方法实现:*
方法一:导航控制器全屏滑动返回效果
当用户在界面左边拖动,就会触发滑动手势方法,并且有滑动返回功能,说明系统手势触发了方法,即调用了target的action方法,也就是说action方法内已经实现侧滑返回。
系统自带的滑动手势interactivePopGestureRecognizer
- (void)viewDidLoad {
[super viewDidLoad];
NSLog(@"%@",self.interactivePopGestureRecognizer);
打印结果知:
1.系统自带的手势是UIScreenEdgePanGestureRecognizer类型对象,屏幕边缘滑动手势
2.系统自带手势target是_UINavigationInteractiveTransition类型的对象
3.target调用的action方法名叫handleNavigationTransition:
全屏滑动代码块实现
- (void)viewDidLoad {
[super viewDidLoad];
id target = self.interactivePopGestureRecognizer.delegate;
UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:target action:@selector(handleNavigationTransition:)];
pan.delegate = self;
[self.view addGestureRecognizer:pan];
self.interactivePopGestureRecognizer.enabled = NO;
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
if (self.childViewControllers.count == 1) {
return NO;
return YES;
导航控制器全屏滑动注意点:
1.禁止系统自带滑动手势使用。
2.只有导航控制器的非根控制器才需要触发手势,使用手势代理,控制手势触发。
完成、这样就搞定了, 亲测此方法会与界面有滑动手势的产生冲突,因此有第二种方法!
以上方法参考原文链接如下:)
方法二:实现自定义导航控制器边缘滑动返回
方法二的实现原理和方法一一样,只不过它还是使用的系统的边缘手势实现侧滑返回功能。只需要在每个类里面添加如下代码块:
写在.m中, 别忘了遵守 UIGestureRecognizerDelegate协议。
@property (nonatomic, strong) UIViewController *currentShowVC;
-(void)viewWillAppear:(BOOL)animated {
self.navigationController.interactivePopGestureRecognizer.delegate =(id)self;
self.navigationController.interactivePopGestureRecognizer.enabled = YES;
if (self.navigationController.viewControllers.count == 1){
self.currentShowVC = N
[SharedAppDelegate setTabBarHidden:NO animated:YES];
如果不是根控制器,就设置当前导航控制器为其本身。
self.currentShowVC = self;
[SharedAppDelegate setTabBarHidden:YES animated:NO];
手势的代理方法
-(BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
if (gestureRecognizer == self.navigationController.interactivePopGestureRecognizer) {
当前导航控制器是根视图控制器
return (self.currentShowVC == self.navigationController.topViewController);
不要隐藏tabbar
[SharedAppDelegate setTabBarHidden:NO animated:NO];
return YES;
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:15133次
排名:千里之外
原创:15篇
(2)(4)(4)(7)(1)11:05 提问
返回后视图的导航条消失了
使用 storyboard 创建了一个带有 navigation bar
的项目。其中有从ViewA点击一个按钮打开ViewB的功能,这一段实现了。然后我用一个取消键返回ViewA。在取消之后,返回ViewA成功了,但是导航条没有显示。而且是ViewA中有导航条,ViewB中没有。
请高手指点一下,谢谢。
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
EditViewController *viewController = (EditViewController *)[storyboard instantiateViewControllerWithIdentifier:@"EditViewController"];
[self presentViewController:viewController animated:NO completion:NULL];
- (IBAction)cancelButtonPressed:(id)sender {
if ( lables != NULL) {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
ScannerViewController *viewController = (ScannerViewController *)[storyboard instantiateViewControllerWithIdentifier:@"ScannerViewController"];
[self presentViewController:viewController animated:NO completion:NULL];
[self.navigationController popViewControllerAnimated:YES];
按赞数排序
实现self.navigationController弹出展现viewB。要用到presentviewcontroller 和dismissviewcontroller
[self dismissViewControllerAnimated:YES completion:nil];
根据你的情况最好用到UINavigationController
[self.navigationController pushViewController:viewController animated:YES];
[self.navigationController popViewControllerAnimated:YES];
其他相似问题Objective-C ,ios,iphone开发基础:多个视图(view)之间的切换2,使用导航栏控制,以及视图之间传值。 - 推酷
Objective-C ,ios,iphone开发基础:多个视图(view)之间的切换2,使用导航栏控制,以及视图之间传值。
首先需要说明的是每个应用程序都是一个window,背景色为黑色。在window上可以跑多个view进行来回切换,下面就通过手动写代码来体现导航栏切换view的原理。
第一步,新建一个single view工程,然后再新建一个带xib文件的UIviewController。
程序结构如下图:
第二步,在
cidpAppDelegate.m
文件中修改
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchO
方法,在函数体中实例化一个UINavigationController对象,在初始化的时候将RootViewController(根视图控制器)初始化为self.viewController,然后将
self.window.rootViewController 初始化为UINavigationController对象&
修改代码如下:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.viewController = [[cidpViewController alloc] initWithNibName:@&cidpViewController& bundle:nil];
UINavigationController* navi = [[[UINavigationController alloc] initWithRootViewController:self.viewController]autorelease];
self.window.rootViewController =
[self.window makeKeyAndVisible];
return YES;
原函数代码如下:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.viewController = [[cidpViewController alloc] initWithNibName:@&cidpViewController& bundle:nil];
self.window.rootViewController = self.viewC
[self.window makeKeyAndVisible];
return YES;
第三步:在cidpViewController.h文件中添加方法
-(IBAction)goN
并在cidpViewController.m文件中实现:
实现代码如下:
-(IBAction)goNext{
//实例化一个试图对象(即将要跳转的试图),
Second* s = [[Second alloc] initWithNibName:@&Second& bundle:nil];
//控制试图加载的样式,一些简单的效果
s.modalTransitionStyle = UIModalTransitionStyleFlipH
//将导航栏添加在跳转后的试图上,
[self.navigationController pushViewController:s animated:YES];
第四步:在cidpViewController.m文件中添加导航栏的标题和为导航栏添加BarButtonItem。
- (void)viewDidLoad
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.navigationItem.title = @&Movie&;
self.navigationItem.leftBarButtonItem =[[UIBarButtonItem alloc] initWithTitle:@&next& style:UIBarButtonItemStylePlain target:self action:@selector(goNext)];
这样已经实现了两个视图之间的来回切换,不过为了实现返回button的原理,继续在第二个视图中添加一个button来返回,以彰显原理。
第五步:在第二个视图里面添加返回按钮的代码,在Second.h文件中声明方法- (IBAction)goBack:(id)并在Second.m文件中实现:
实现代码:
- (IBAction)goBack:(id)sender{
[self.navigationController popViewControllerAnimated:YES];
在Second.m文件中的- (void)viewDidLoad方法中为导航栏添加标题,并且添加返回按钮,是返回按钮使用函数指针的形式调用goBack来返回,
- (void)viewDidLoad
[super viewDidLoad];
//添加标题。
self.navigationItem.title = @&second&;
//初始化返回按钮。
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@&back& style:UIBarButtonItemStyleBordered target:self action:@selector(goBack:)];
// Do any additional setup after loading the view from its nib.
这样就实现了导航栏来回切换视图的原理。其实关键的原理就是
[self.navigationController pushViewController:s animated:YES];和
[self.navigationController popViewControllerAnimated:YES];
类似于压栈和出栈,其实就是这样的喊 push和pop嘛。
已发表评论数()
请填写推刊名
描述不能大于100个字符!
权限设置: 公开
仅自己可见
正文不准确
标题不准确
排版有问题
主题不准确
没有分页内容
图片无法显示
视频无法显示
与原文不一致IOS SDK6/Xcode4.5开始在Storyboad中新增很多功能对可视化的开发页面布局,导航更加方便,下面就写一下各种导航的实现。
1、不用像Xcode4之前必须删除默认的viewcontroller,然后拖一个navigation controller,然后才能实现导航。只需要选择默认的viewcontroller ,在菜单上选择editor-embed in-
2、下面实现导航最简单的就是next,back,只需要按住ctr直接拖线就好了,这里有一个Storyboard Segue-Identifier这个值最好填上,可以在代码里面用到
这个Identifier的值可以一般在两个地方会用
1页面切换是方便传值,代码如何
2如果一个页面有个导航路径,需要通过代码判断导航到哪个目的viewcontroller也就是执行哪个Identifier,代码如下
3、自定义导航,默认提供了,push,modal,popover,replace,还有就是custom,可以自定义class实现。
下面自定义了一个Back功能的导航,代码如下
4、返回任意一个viewcontroller,官方称 unwind segues,如果你想让一个viewcontroller可以在其他任意的viewcontroller直接导航回来那么只需要在这个viewcontroller下重写以下方法
只要你在每个viewcontroller中重写了-(ibaction)name:(uistoryboardsegue *)segue,那么当你直接拖线指向Exit图标的时候就会出现你所有实现的方法,当你选择哪个方法就返回到实现这个方法的viewcontroller
基本上就这些,希望对初学者有所帮助。
阅读(...) 评论()iOS viewController添加导航条以及返回跳转选择_iOS_IThao123 - IT行业第一站
给单独的viewcontroller或者在Appdelegate的主页面添加导航条,只要在viewcontroller上添加navigationcontroller,在添加此navigationcontroller即可
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
& & self.window = [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen]bounds]];
& & ViewController *mainView = [[ViewController alloc]init];
& & UINavigationController *navi = [[UINavigationController alloc]initWithRootViewController:mainView];
& & navi.navigationBar.backgroundColor = [UIColor blueColor];
& & [self.window setRootViewController:navi];
& & [self.window makeKeyAndVisible];
& & return YES;
导航条的字体和颜色的设置
self.navigationController.navigationBar.titleTextAttributes
=& [NSDictionary dictionaryWithObject:[UIColor whiteColor]
forKey:UITextAttributeTextColor]; // --- 字体颜色
& & [self.navigationController.navigationBar&setBackgroundImage:[UIImage&imageNamed:@"BJ.png"] forBarMetrics:UIBarMetricsDefault]; //&&&背景色
导航条跳转页面的考虑
对于用navigationcontroller来跳转页面的时候,其实是执行堆栈的进栈和出栈的操作,要想释放内存,那么在来回跳转的时候,就要考虑几个问题了
1 A =&B=&C=&D,D=&A 有根视图的话 (HOME)[self.navigationController popToRootViewControllerAnimated:YES];& D=&C& (每一个界面返回上一层)[self.navigationController popViewControllerAnimated:YES];& 返回到上一层,并且传递参数CViewController *cvc = [CViewController alloc]init];cvc.str = self.[self.navigationController popToViewController:cvc animated:true];返回到上一层后,上一页面显示后要接收参数,并刷新。注意此时应该在viewDidAppear中进行判断并接收传递的值-(void)viewDidAppear:(BOOL)animated{& //判断并接收返回的参数}
2&&A =&B=&C=&D=&E,E=&B=&C=&E
因为B在之前已经出现过,不能在E中直接PUSH到B,因为那样已经是两个B了,增加内存,所以在跳转的时候,就要进行判断是否之前已经出现过B了,出现过,则直接push。这样push到的是原有的B,不会在内存中重新生成一个B了。
&NSArray *array = self.navigationController.viewC
& & for (UIViewController *vc in array) {
& & & & if ([vc isKindOfClass:[BXXXViewController class]]) {
或者知道每个界面的指针
[self.navigationController
popToViewController: [self.navigationController.viewControllers
&&&&&&&& objectAtIndex: ([self.navigationController.viewControllers count] -4)]
&&&&&&&&&&&&&&& animated:YES];
在使用时,根据自己返回层的需要,只要改变一下&-4&这个数字就可以达到目的了

我要回帖

更多关于 水利工程预算软件 的文章

 

随机推荐