我們在iPhone開發(fā)的過程中,估計(jì)UINavgationController是最最常用的控件之一吧,截下來我就用一個(gè)demo來舉例導(dǎo)航控制器的應(yīng)用。包含了tableview中增刪查改的功能。
創(chuàng)新互聯(lián)致力于網(wǎng)站設(shè)計(jì)、做網(wǎng)站,成都網(wǎng)站設(shè)計(jì),集團(tuán)網(wǎng)站建設(shè)等服務(wù)標(biāo)準(zhǔn)化,推過標(biāo)準(zhǔn)化降低中小企業(yè)的建站的成本,并持續(xù)提升建站的定制化服務(wù)水平進(jìn)行質(zhì)量交付,讓企業(yè)網(wǎng)站從市場競爭中脫穎而出。 選擇創(chuàng)新互聯(lián),就選擇了安全、穩(wěn)定、美觀的網(wǎng)站建設(shè)服務(wù)!
#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)id delegate; @end
#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]; //首先要添加右上角的一個(gè)edit按鈕,按鈕按下去可以設(shè)置可以編輯 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
http://download.csdn.net/detail/s10141303/5999165
==================== 迂者 丁小未 CSDN博客專欄=================
MyBlog:http://blog.csdn.net/dingxiaowei2013 MyQQ:1213250243
Unity QQ群:858550 cocos2dx QQ群:280818155
====================== 相互學(xué)習(xí),共同進(jìn)步 ===================
轉(zhuǎn)載請注明出處:http://blog.csdn.net/dingxiaowei2013/article/details/10170290