[IOS]非常不错的导航控制器的应用Demo

我们在iPhone开发的过程中,估计UINavgationController是最最常用的控件之一吧,截下来我就用一个demo来举例导航控制器的应用。包含了tableview中增删查改的功能。

创新互联致力于网站设计、做网站,成都网站设计,集团网站建设等服务标准化,推过标准化降低中小企业的建站的成本,并持续提升建站的定制化服务水平进行质量交付,让企业网站从市场竞争中脱颖而出。 选择创新互联,就选择了安全、稳定、美观的网站建设服务!

导航控制器的应用Demo

实现步骤:

1.创建一个Empty项目,命名为Navdemo。

2.创建一个根视图控制器,继承自UINavgationController,命名为FirstViewController。

[IOS]非常不错的导航控制器的应用Demo

EditViewController.h:

#import  #import "Person.h" #import "ChangeViewController.h" @interface EditViewController : UIViewController @property(copy,nonatomic)Person *per;//对象 @property (retain, nonatomic) IBOutlet UITextField *name; @property (retain, nonatomic) IBOutlet UITextField *age; @property(assign,nonatomic) int row; //位置 @property(nonatomic,retain)iddelegate; @end

EditViewController.m:

#import "EditViewController.h"  @interface EditViewController ()  @end  @implementation EditViewController  - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {     self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];     if (self) {         self.title = @"信息修改";     }     return self; }  -(void)viewWillAppear:(BOOL)animated {     self.name.text = self.per.name;     self.age.text = [NSString stringWithFormat:@"%d",self.per.age]; }  - (void)viewDidLoad {     [super viewDidLoad];     //首先要添加右上角的一个edit按钮,按钮按下去可以设置可以编辑     UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithTitle:@"返回" style:UIBarButtonItemStyleBordered target:self action:@selector(itemLeftButtonClick:)]; 	self.navigationItem.leftBarButtonItem = button;          UIBarButtonItem *button1 = [[UIBarButtonItem alloc] initWithTitle:@"保存" style:UIBarButtonItemStyleBordered target:self action:@selector(itemRightButtonClick:)];     self.navigationItem.rightBarButtonItem = button1; } //返回 -(void)itemLeftButtonClick:(id)sender {     [self.navigationController popViewControllerAnimated:YES]; } //保存 -(void)itemRightButtonClick:(id)sender {     [self changedata];     [self.navigationController popViewControllerAnimated:YES]; }   - (void)changedata {     self.per.name = self.name.text;     self.per.age = [self.age.text intValue];     if ([self.delegate respondsToSelector:@selector(changeData:Per:)]) {         [self.delegate changeData:self.row Per:self.per];     } }  - (void)dealloc {     [_name release];     [_age release];     [super dealloc]; } @end


Demo源文件:

http://download.csdn.net/detail/s10141303/5999165


==================== 迂者 丁小未 CSDN博客专栏=================

MyBlog:http://blog.csdn.net/dingxiaowei2013             MyQQ:1213250243

Unity QQ群:858550         cocos2dx QQ群:280818155

====================== 相互学习,共同进步 ===================

转载请注明出处:http://blog.csdn.net/dingxiaowei2013/article/details/10170290

欢迎关注我的微博:http://weibo.com/u/2590571922

网页名称:[IOS]非常不错的导航控制器的应用Demo
地址分享:http://pwwzsj.com/article/jihpgg.html