ios开发-Storyboard在多个viewcontroller之间导航的实现

IOS SDK6/Xcode4.5开始在Storyboad中新增很多功能对可视化的开发页面布局,导航更加方便,下面就写一下各种导航的实现。

1、不用像Xcode4之前必须删除默认的viewcontroller,然后拖一个navigation controller,然后才能实现导航。只需要选择默认的viewcontroller ,在菜单上选择editor-embed in- Screen Shot 2012-12-21 at 9.06.17 AM.png

2、下面实现导航最简单的就是next,back,只需要按住ctr直接拖线就好了,这里有一个Storyboard Segue-Identifier这个值最好填上,可以在代码里面用到

Screen Shot 2012-12-21 at 9.13.47 AM.png

这个Identifier的值可以一般在两个地方会用

1页面切换是方便传值,代码如何


Screen Shot 2012-12-21 at 9.17.47 AM.png

2如果一个页面有个导航路径,需要通过代码判断导航到哪个目的viewcontroller也就是执行哪个Identifier,代码如下


Screen Shot 2012-12-21 at 9.20.07 AM.png

3、自定义导航,默认提供了,push,modal,popover,replace,还有就是custom,可以自定义class实现。

Screen Shot 2012-12-21 at 9.21.22 AM.png

下面自定义了一个Back功能的导航,代码如下

Screen Shot 2012-12-21 at 9.23.25 AM.png

Screen Shot 2012-12-21 at 9.24.32 AM.png

4、返回任意一个viewcontroller,官方称 unwind segues,如果你想让一个viewcontroller可以在其他任意的viewcontroller直接导航回来那么只需要在这个viewcontroller下重写以下方法Screen Shot 2012-12-21 at 9.30.53 AM.png


Screen Shot 2012-12-21 at 9.32.39 AM.png

只要你在每个viewcontroller中重写了-(ibaction)name:(uistoryboardsegue *)segue,那么当你直接拖线指向Exit图标的时候就会出现你所有实现的方法,当你选择哪个方法就返回到实现这个方法的viewcontroller

基本上就这些,希望对初学者有所帮助。

 

 

 
分类:  Objective-C

Objective-C

 
摘要: IOS SDK6/Xcode4.5开始在Storyboad中新增很多功能对可视化的开发页面布局,导航更加方便,下面就写一下各种导航的实现。1、不用像Xcode4之前必须删除默认的viewcontroller,然后拖一个navigation controller,然后才能实现导航。只需要选择默认的viewcontroller ,在菜单上选择editor-embed in- 2、下面实现导航最简单的就是next,back,只需要按住ctr直接拖线就好了,这里有一个Storyboard Segue-Identifier这个值最好填上,可以在代码里面用到这个Identifier的值可以一般在两个地方会 阅读全文
posted @  2012-12-21 09:41 阿新 阅读(266) |  评论 (0)  编辑
 
摘要: 在scanview中添加扫描区域ZBarReaderViewController *reader = [ZBarReaderViewController new]; reader.readerDelegate = self; //CGRect frame= CGRectMake(20, 30, 320, 260); reader.scanCrop= CGRectMake(0.2, .1, .47, .8); 自定义scanview添加一个自定义的扫描框- (UIView *)setOverlayPickerView{ UIView *v=[[UIView alloc]... 阅读全文
posted @  2012-12-07 12:20 阿新 阅读(41) |  评论 (0)  编辑
 
摘要: http://pastebin.com/wSVW1tRcCGRect scanCropThe region of the video image that will be scanned, innormalized image coordinates. Note that the video image is in landscape mode (default {{0, 0}, {1, 1}})The coordinates for all of the arguments is in a normalized float, which is from 0 - 1. So, in norma 阅读全文
posted @  2012-12-07 07:27 阿新 阅读(15) |  评论 (0)  编辑
 
摘要: Assuming you have storyboard, go to storyboard and give your VC an identifier (inspector), then do: UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];UIViewCon... 阅读全文
posted @  2012-12-04 09:13 阿新 阅读(37) |  评论 (0)  编辑
 
摘要: 代码--(IBAction)uploadAction:(id)sender{NSString*urlstring=self.urlTextField.text;//NSString*poststr=@"";NSData*imgData=UIImageJPEGRepresentation(self.previewImageView.image,0.9f);NSString*boundary=@"0xKhTmLbOuNdArY";NSString*contentType=[NSStringstringWithFormat:@"multipart/f 阅读全文
posted @  2012-11-27 11:37 阿新 阅读(17) |  评论 (0)  编辑
 
摘要: Here is a simple and sample code that demonstrate the photo slide function with zoom using uiscrollview.this is the first photoslidingzooming in particular photo1. first drag three photos to your project , size not important .2 viewcontroller.h 's code#import <UIKit/UIKit.h>@interface View 阅读全文
posted @  2012-06-28 14:04 阿新 阅读(220) |  评论 (0)  编辑
 
摘要: -(void)viewDidLoad{[superviewDidLoad];[theScrollViewsetContentSize:CGSizeMake(3*theScrollView.bounds.size.width,theScrollView.bounds.size.height)];[theScrollViewsetPagingEnabled:YES];CGRectaFrame=theScrollView.bounds;UIView*view;NSLog(@"Frame:%@",NSStringFromCGRect(aFrame));view=[[UIViewal 阅读全文
posted @  2012-06-16 19:15 阿新 阅读(59) |  评论 (0)  编辑
 
摘要: -(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toOrientationduration:(NSTimeInterval)duration{if(toOrientation==UIInterfaceOrientationLandscapeLeft||toOrientation==UIInterfaceOrientationLandscapeRight){[UIViewbeginAnimations:nilcontext:NULL];{[UIViewsetAnimationDuration:1.0];}[UIVie 阅读全文
posted @  2012-06-06 21:02 阿新 阅读(100) |  评论 (0)  编辑
 
摘要: 该例子添加UITableView编辑功能具体功能如下功能很简单但很实用@implementationAppDelegate@synthesizewindow=_window;@synthesizeviewController=_viewController;@synthesizenavigationController=_navigationController;@synthesizearray=_array;-(BOOL)application:(UIApplication*)applicationdidFinishLaunchingWithOptions:(NSDictionary*)la 阅读全文
posted @  2012-05-04 11:39 阿新 阅读(618) |  评论 (0)  编辑
 
摘要: 目前最流行的跨平台交互是采用http协议通过JSON对象进行互操作。这种方式最简单,也很高效。webservice+xml的方式似乎已经过时。下面是我做的一个例子webapi的代码 View CodepublicIEnumerable<Product>GetAllProducts(){Console.WriteLine(DateTime.Now.ToLongTimeString()+":receiverequest.");returnnewList<Product>{newProduct(){Id=1,Name="Gizmo1", 阅读全文
posted @  2012-04-06 10:22 阿新 阅读(1734) |  评论 (2)  编辑
 
摘要: UsingSBJson, to convert a object to JSON string, you have to override theproxyForJsonmethod. Like the following,The .h file,@interface MyCustomObject : NSObject { NSString *receiverFirstName; NSString *receiverMiddleInitial; NSString *receiverLastName; NSString *receiverLastName2;}@property (non... 阅读全文
posted @  2012-04-04 12:54 阿新 阅读(119) |  评论 (0)  编辑
 
摘要: 最近因为项目需求,需要将一些自定义的类序列化为JSON,网上有很多好用的第三方序列化工具,但都只能自动序列化一些基本类型,如NSNumber,NSString与NSDictionary这种,没有一种第三方工具提供直接将自定义类序列化的方法(至少据我所知:),而对于这种序列化自定义的类的需求,网上能查到的方法只有将自定义的类手动的转存为一个NSDictionary,然后再使用第三方工具来序列化。例如对于一个类Foo,有如下定义:?1234567891011121314151617181920212223242526272829303132333435363738394041@interface  阅读全文
posted @  2012-04-02 06:41 阿新 阅读(95) |  评论 (0)  编辑
 
摘要: UIScrollView在开发中是一个非常常用的控件,UIScrollView具有水平、垂直滚动和缩放效果。但是尽然没有响应单击事件这个事件。而这个事件在日常的交互中是非常需要的。比如当用于单击或轻触图片的某个位置时,给于一些交互性提示。 下面我将用例子说明一下如何给UIScrollView添加一个单击的响应。 代码如下: 添加一个自定义的UIScrollView,命名:UITouchScrollView UITouchScrollView.h代码如下#import<Foundation/Foundation.h>@protocolUIScrollViewTouchesDelega 阅读全文
posted @  2012-03-30 14:28 阿新 阅读(1731) |  评论 (0)  编辑
 
摘要: 插上上网卡以后自动加载一个光盘映像 运行里面的程序把该装的都装了就可以了 至于那个系统自带的拨号程序 完全是废柴 打开网络设置 创建一个新服务 下拉菜单选择HUAWEIMobile Modem 创建 高级 厂商下拉选其他 型号选哪个问题都不大 好 配置这么写 电话号码 #777 账户名称 [email protected] 密码 vnet.mobi 拨号成功 阅读全文
posted @  2012-03-18 20:44 阿新 阅读(147) |  评论 (0)  编辑
 
摘要: XCode4.2.1 使用NavigationController实现View切换现在网上有很多关于NavigationController实现页面之间导航,但是大部分都是老版本的实现方式,基于Window base application 模板实现,但新版本XCode 4.2.1没有这个模板,对于新手就算拿到源代码也不知道如何下手。老版本实现的NavigationController项目源代码 但是新版的没有这个模板比如Single view application的项目直接生存ViewController不带Window和 mainWindow.xib文件 修改AppDelegate... 阅读全文
posted @  2012-02-16 16:56 阿新 阅读(3121) |  评论 (5)  编辑
 
摘要: 1.AddInfo *control = [[AddInfo alloc] init]; [self presentModalViewController:control animated:YES]; [control release]; 描述:通过事件进行跳转 [self dismissModalViewControllerAnimated:YES]; 描述:通过事件进行返回。 2.[self.navigationController pushViewController:subTableViewController animated:YES]; 描述:通过 NSNavigat... 阅读全文
posted @  2012-02-14 16:26 阿新 阅读(357) |  评论 (0)  编辑

你可能感兴趣的:(controller)