fromyear一带一路是什么意思思

 上传我的文档
 下载
 收藏
如有问题敬请留言。概不还价、免费索要,请勿扰!
 下载此文档
正在努力加载中...
会计自愿性信息年动机实证研究
下载积分:2000
内容提示:会计自愿性信息年动机实证研究---优秀硕士毕业论文,本科毕业设计参考文献资料。支持复制编辑!!!
文档格式:PDF|
浏览次数:0|
上传日期: 17:07:48|
文档星级:
该用户还上传了这些文档
会计自愿性信息年动机实证研究.PDF
官方公共微信您所在位置: &
&nbsp&&nbsp&nbsp&&nbsp
TH农信联社信用风险管理研究.pdf60页
本文档一共被下载:
次 ,您可免费全文在线阅读后下载本文档
文档加载中...广告还剩秒
需要金币:158 &&
优秀博硕毕业论文,完美PDF内部资料、支持编辑复制,值得参考!!!(仅供学术交流参考用)
你可能关注的文档:
··········
··········
2007年美国次贷危机引起的全球性金融危机,引起了世界各国金融机构对信
用风险的高度重视,我国银监会和各大行纷纷做出反应,出台各种措施提高风险
应对能力,取得了很进步。而农信社作为中国金融市场的重要成分,由于其自身
的种种限制,导致其应对信用风险的能力和研究水平低下。面临日益复杂的市场
环境和日益激烈的市场竞争,农信社要跟上时代和经济的发展,必须提高自身经
营水平,尤其要提高信用风险管理水平。
论文结合TH农信联社的实际情况对其信用风险管理展开了全面的研究分析。
首先,论文确定了研究的目的、意义,研究的现状、思路和方法,并通过介绍农
信社和信用风险的含义、特点,农信社的管理原则和流程等,为论文研究做了充
分的理论铺垫。然后具体分析了TH农信联社信用风险管理的现状,并总结出其中
的问题,为了挖掘信用风险产生的原因,论文先详细介绍了信用风险在贷款前、
中、后的具体表现,然后结合案例联系实际,总结信用风险发生的特点和原因。
按照信用风险的管理流程,即风险识别、计量、监测和控制,论文进一步分析了
TH农信联社的若干指标,发现该农联社虽然在有些方面有长足的进步,但是依然
面临极大的信用风险。最后,论文结合以上研究分析了应对和防范信用风险的具
体措施,并做出结论,分析研究存在的不足,指出未来研究的努力方向。
论文按照发现问题、分析问题、解决问题的基本思路,通过现状研究发现问
题,通过风险表现、案例分析、指标计算分析问题,提出应对和防范措施解决问
题,形成了系
正在加载中,请稍后...IOS开发-表视图LV3导航控制器 - 推酷
IOS开发-表视图LV3导航控制器
学到这里感觉有点难了,
其实这篇文章再草稿箱里放了好久了~ 最近对于学习的热情下降了。这不行~抓紧学习走起!
在这一章节的学习中主要针对导航控制器及表视图来建立多视图的应用,
首先要了解一些概念--
1.导航控制器
UINavigationController是用于构建分层应用程序的主要工具,它在管理以及换入和换出多个内容视图方面与UITabBarController较为类似。
两者间的不动之处在于UINavigationController是作为栈来实现,这让他非常适用于处理分层的数据。栈:先进后出,后进先出。
2.控制器栈
根控制器(root view controller) 子控制器(subcontroller)&
&&& 在设计导航控制器时,需要指定用户看到的第一个视图,该视图处在导航栈的最底层,其对应的控制器称为根控制器.所以不要把根控制器理解为导航控制器.根控制器也是导航控制器的一个子控制器.
&&& 在术语上把栈中的除了根控制器其余的控制器称为子控制器.
&&& 一般地,根控制器对应的视图上有各个子控制器视图的入口,回退到根视图然后再切换各个子视图.
&&& 默认地,导航控制器会自动在当前子控制器对应视图的导航栏的右端加一个返回按钮,名称是上一个视图的标题.
3. 导航按钮.
&& 导航按钮类似于网页上的后退按钮,当点击时,当前的视图控制器出栈,栈中的下一个视图成为当前视图.
4. 其它术语:
扩展图标(accessory icon)
扩展指示器(disclosure indicator)
,告知将切换到另一个视图,它以一个灰色箭头表示.
细节展示按钮(detail disclosure button)
不仅是一个图标,它还是一个可单击的控件.
下面将建立一个由6个部分组成的分层应用程序
主视图如下:
即有6子控制器&
第一个子控制器是展示按钮视图 包含一个细节展示按钮
第二个子控制器是校验表视图 “多选一”的操作
第三个子控制器是行控制视图 在每行的扩展视图中添加了一个可单击的按钮
第四个子控制器是可移动行视图 可以对行进行重新排序
第五个子控制器是可删除行视图 允许删除行的编辑模式
第六个子控制器是可编辑详细信息视图 对详细信息的编辑模式 - 这里的编码可能有点问题~
---------------------------看到只有七个界面,以为会很容易,谁知…--------------------------------
1.首先,建立一个空项目。从零开始。
然后,建立FirstLevelViewController 及 SecondLevelViewController ,
在建文件的同时让它们继承于UITableViewCell,XCode会帮我们自动实现协议抽象方法
现在项目的骨架如下:
2.下一步,在AppDelegate.m中启用委托加载视图&
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
FirstLevelViewController *first = [[FirstLevelViewController alloc] init];
UINavigationController *navigation = [[UINavigationController alloc] initWithRootViewController:first];
self.window.rootViewController =
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
3.启动运行,一级页面效果 效果如下: 空空白白就一个tableView
4.接下来要编写第一个子控制器的内容,由于它还嵌套了另一个视图,所以这里先从里到外从详情页写起。
建立DisclosureDetailViewController及DisclosureDetail.xib&
DisclosureDetailViewController.h编码
#import &UIKit/UIKit.h&
@interface DisclosureDetailViewController : UIViewController
@property (retain, nonatomic) IBOutlet UILabel *
@property (copy, nonatomic) NSString *
DisclosureDetailViewController.m相关编码
@synthesize
@synthesize
- (void)viewWillAppear:(BOOL)
[super viewWillAppear:animated];
self.label.text = self.
-(void) dealloc
[label release];
[message release];
[super dealloc];
DisclosureDetail.xib上放一个label&
把DisclosureDetail.xib的View及label 与DisclosureDetailViewController关联起来。
5.修改展示按钮控制器,建立按钮视图
这里需要建立第一个子控制来指向刚才构建的
DisclosureDetailViewController
#import &SecondLevelViewController.h&
@class DisclosureDetailViewC
@interface DisclosureButtonViewController : SecondLevelViewController
@property (nonatomic,retain) NSArray *
@property (nonatomic,retain) DisclosureDetailViewController *childC
.m文件关键代码
//加载数据
- (void)viewDidLoad
NSArray *array =[[NSArray alloc]initWithObjects:@&toy story&,@&a bug's life&,@&toy story1&,@&jay&, @&toy story2&,@&hacker&,@&toy story3&,@&1326&, @&toy story4&,@&coding&,
self.list =
[array release];
[super viewDidLoad];
// Do any additional setup after loading the view.
//释放销毁对象
-(void)dealloc
[list release];
[childController release];
[super dealloc];
//返回行数
-(NSInteger) tableView :(UITableViewCell*) tableview numberOfRowsInSection:(NSInteger)section
return [list count];
//绑定每行数据
-(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
static NSString *DisclocsutreButtonCellIdetifier = @&DisclosutreButtonCellIdetifier&;
UITableViewCell *cell =[tableView dequeueReusableCellWithIdentifier:DisclocsutreButtonCellIdetifier];
if(cell ==nil)
cell =[[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:DisclocsutreButtonCellIdetifier]autorelease];
NSUInteger row = [indexPath row];
NSString *rowString = [list objectAtIndex:row];
cell.textLabel.text = rowS
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureB
[rowString release];
//处理不选中事件 这里要区别Deselect与Select
-(void) tableView:(UITableView*)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
UIAlertView *alert = [[UIAlertView alloc ]initWithTitle:@&Hey,Man& message:@&drill down,touch that instead& delegate:nil cancelButtonTitle:@&Won't happen again& otherButtonTitles:nil];
[alert show];
[alert release];
//展示按钮方法
-(void) tableView:(UITableView*)tableView
accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
if(childController ==nil)
childController = [[DisclosureDetailViewController alloc]initWithNibName:@&DisclosureDetail& bundle:nil];
childController.title = @&Disclosure Button Pressed&;
NSUInteger row = [indexPath row];
NSString *selectMovie=[list objectAtIndex:row];
NSString *detailMessage = [[NSString alloc]initWithFormat:@&You pressed the disclosure button for %@.&,selectMovie];
childController.message = detailM
childController.title = selectM
[detailMessage release];
[self.navigationController pushViewController:childController animated:YES];//将详情视图推入控制器栈
6.回到FirstLevelViewController.m为Disclosure及其附属视图添加一个按钮控制器实例
关键代码:
- (void)viewDidLoad
self.title =@&Frist Level 1326&;
NSMutableArray *array = [[NSMutableArray alloc]init];
DisclosureButtonViewController *disclosureButtonController = [[DisclosureButtonViewController alloc] initWithStyle:UITableViewStylePlain];
disclosureButtonController.title = @&Disclosure Buttons&;
disclosureButtonController.rowImage = [UIImage imageNamed:@&disclosureButtonControllerIcon.png&];
[array addObject:disclosureButtonController];
[disclosureButtonController release];
self.controllers =
[array release];
[super viewDidLoad];
当然,也要实现tableView的数据加载的三个方法及相关头文件引入。
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
// Return the number of sections.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
// Return the number of rows in the section.
return [self.controllers count];
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
static NSString *CellIdentifier = @&FristLevelCell&;
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(cell ==nil)
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]autorelease];
SecondLevelViewController *controller = self.controllers[indexPath.row];
cell.textLabel.text = controller.
cell.imageView.image = controller.rowI
cell.accessoryType = UITableViewCellAccessoryDisclosureI
// Configure the cell...
编译运行,效果如下:
添加第一个二级控制器之后的应用程序。
展示按钮视图
点击行视图
详细信息视图
通过4-6步骤的编码,就初步完成NavNice这个实例的1/6的工程,也看到多视图应用小小的成果。这看起来灰常的NICE~
第二个子控制器
依旧是建表视图,依旧是继承于SecondLevelViewController
#import &SecondLevelViewController.h&
@interface CheckListViewController : SecondLevelViewController
@property (nonatomic,retain) NSArray *
@property (nonatomic,retain) NSIndexPath *lastIndexP
.m文件关键代码:
//数据初始化
- (void)viewDidLoad
NSArray *array = [[NSArray alloc]initWithObjects:@&hi,man1326&,@&4y&,@&viewDidLoad&,@&dealloc&,@&fristblood&,
@&double kill&,@&nice&,@&...&,@&okokok&,nil];
self.list =
[array release];
[super viewDidLoad];
// Do any additional setup after loading the view.
//释放资源
-(void) dealloc
[list release];
[lastIndexPath release];
[super dealloc];
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
return [list count];
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
static NSString *CheckMarkCellIdentifier = @&CheckMarkCellIdentifier&;
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CheckMarkCellIdentifier];
if(cell==nil)
cell =[[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CheckMarkCellIdentifier]autorelease];
//从这个单元和当前选项提取行
NSUInteger row = [indexPath row];
NSUInteger oldRow = [lastIndexPath row];
cell.textLabel.text = [list objectAtIndex:row];//将它分配给单元的标题
cell.accessoryType = (row==oldRow&&lastIndexPath!=nil)?
UITableViewCellAccessoryCheckmark:UITableViewCellAccessoryN//如果选中则设图标 否则不显示任何东西
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
//获取选中行
int newRow = [indexPath row];
int oldRow = (lastIndexPath !=nil)?[lastIndexPath row]:-1;
if(newRow !=oldRow)
//修改图标
UITableViewCell *newCell = [tableView cellForRowAtIndexPath:indexPath];
newCell.accessoryType = UITableViewCellAccessoryC
UITableViewCell *oldCell = [tableView cellForRowAtIndexPath:lastIndexPath];
oldCell.accessoryType = UITableViewCellAccessoryN
lastIndexPath
} [tableView deselectRowAtIndexPath:indexPath animated:YES];//告诉表视图取消选中不凸显 }
8.添加校验表到控制器实例
在FirstLevelViewController.m添加CheckListController的索引表视图
- (void)viewDidLoad
self.title =@&Frist Level 1326&;
NSMutableArray *array = [[NSMutableArray alloc]init];
//Disclosure Button
DisclosureButtonViewController *disclosureButtonController = [[DisclosureButtonViewController alloc] initWithStyle:UITableViewStylePlain];
disclosureButtonController.title = @&Disclosure Buttons&;
disclosureButtonController.rowImage = [UIImage imageNamed:@&disclosureButtonControllerIcon.png&];
[array addObject:disclosureButtonController];
[disclosureButtonController release];
//Checklist
CheckListViewController *checkListController = [[CheckListViewController alloc]initWithStyle:UITableViewStylePlain];
checkListController.title = @&check one&;
checkListController.rowImage = [UIImage imageNamed:@&checkmarkControllerIcon.png&];
[array addObject:checkListController];
[checkListController release];
self.controllers =
[array release];
[super viewDidLoad];
// Uncomment the following line to preserve selection between presentations.
// self.clearsSelectionOnViewWillAppear = NO;
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonI
编译运行,效果如下:
两行控制器,两行信息
点入check one页面
第三个子控制器
:行上的控件
依旧是建表视图,依旧是继承于SecondLevelViewController,这次命名为
RowControlsController
RowControlsController.h文件代码
#import &SecondLevelViewController.h&
@interface RowControlsController : SecondLevelViewController
@property(nonatomic,retain)NSArray *
-(IBAction)buttonTapped:(id)
RowControlsController.m文件核心代码
-(IBAction)buttonTapped:(id)sender
UIButton *senderButton = (UIButton *)
UITableViewCell *buttonCell = (UITableViewCell*)[senderButton superview];
NSUInteger buttonRow = [[self.tableView indexPathForCell:buttonCell] row];
NSString *buttonTitle = [list objectAtIndex:buttonRow];
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@&You tapped the button& message:[NSString stringWithFormat:@&You tapped the button for %@&,buttonTitle] delegate:nil cancelButtonTitle:@&ok& otherButtonTitles: nil];
[alert show];
[alert release];
- (void)viewDidLoad
NSArray *array = [[NSArray alloc] initWithObjects:@&1326&,@&1234&,@&byebye&,@&fouce&,@&table&,@&nice&,@&good luck&,@&48road&,@&ganker&, nil];
self.list =
[array release];
[super viewDidLoad];
// Do any additional setup after loading the view.
-(void)dealloc
[list release];
[super dealloc];
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
return [list count];
-(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
static NSString * ControlRowIdentifier = @&ControlRowIdentifier&;
UITableViewCell *cell =[tableView dequeueReusableCellWithIdentifier:ControlRowIdentifier];
if(cell ==nil)
cell =[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ControlRowIdentifier];
UIImage *buttonUpImage=[UIImage imageNamed:@&button_up.png&];
UIImage *buttonDownImage = [UIImage imageNamed:@&button_down.png&];
UIButton *button=[UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(0.0, 0.0, buttonUpImage.size.width, buttonUpImage.size.height);
[button setBackgroundImage:buttonUpImage forState:UIControlStateNormal];
[button setBackgroundImage:buttonDownImage forState:UIControlStateHighlighted];
[button setTitle:@&Tag& forState:UIControlStateNormal];
[button addTarget:self action:@selector(buttonTapped:) forControlEvents:UIControlEventTouchUpInside];//注册事件
cell.accessoryView=
NSUInteger row = [indexPath row];
NSString *rowTitle =[list objectAtIndex:row];
cell.textLabel.text= rowT
//选中行委托
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
NSUInteger row = [indexPath row];
NSString *rowTitle =[list objectAtIndex:row];
UIAlertView *alert =[[UIAlertView alloc] initWithTitle:@&you tapped the row& message:[NSString stringWithFormat:@&you tapped %@&,rowTitle] delegate:nil cancelButtonTitle:@&ok& otherButtonTitles: nil];
[alert show];
[alert release];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
10. 在主程序中添加行控件控制器的实例
回到FristLevelViewController,修改ViewDidLoad方法,在中间初始化数据插入关键代码
//Table row
RowControlsController *rowController = [[RowControlsController alloc]initWithStyle:UITableViewStylePlain];
rowController.title = @&Row Controls&;
rowController.rowImage = [UIImage imageNamed:@&rowControlsIcon&];
[array addObject:rowController];
[rowController release];
OK,编译执行,效果如下:
初始化画面-多了行控件的子控制器
点进二级控制器后的界面:
选中行中按钮是弹出的消息窗口
选中行时弹出的提示-
11.第四个控制器-可移动的行
要建立可移动的行,可以使用表视图的setEditing:animated:方法打开
,这个方法带两个BOOLEAN类型的参数,第一个指示编辑模式是否被打开,第二个指示表是否进行动画转换~打开编辑模式后,大量的新委托方法就开始发挥作用,如询问某一行是否可以被编辑或移除,并告知用户是否移除或编辑特定行。
下面,依旧是建表视图,继承SecondLevelViewController,这次命名为MoveMeController。
#import &SecondLevelViewController.h&
@interface MoveMeController : SecondLevelViewController
@property (nonatomic,retain)NSMutableArray *
-(IBAction) toggleM
.m关键代码
//操作方法
-(IBAction)toggleMove
[self.tableView setEditing:!self.tableView.editing animated:YES];
if(self.tableView.editing)
[self.navigationItem.rightBarButtonItem setTitle:@&Done&];
[self.navigationItem.rightBarButtonItem setTitle:@&Move&];
- (void)viewDidLoad
if(list==nil){
NSMutableArray *array = [[NSMutableArray alloc] initWithObjects:@&1623&,@&y2ok&,@&even&,@&qazwsx&,@&by&,@&fly&,@&boom&,nil];
self.list=
[array release];
//初始化按钮
UIBarButtonItem *moveBtn = [[UIBarButtonItem alloc]initWithTitle:@&Move& style:UIBarButtonItemStyleBordered target:self action:@selector(toggleMove)];
self.navigationItem .rightBarButtonItem = moveB
[moveBtn release];
[super viewDidLoad];
// Do any additional setup after loading the view.
-(void)dealloc
[list release];
[super dealloc];
-(NSInteger )tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
return [list count];
-(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
static NSString *MoveMeCellIdentifier = @&MoveMeCellIdentifier&;
UITableViewCell *cell =[tableView dequeueReusableCellWithIdentifier:MoveMeCellIdentifier];
if(cell==nil)
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MoveMeCellIdentifier]autorelease];
cell.showsReorderControl = YES;//启用编辑模式需要设置为yes
NSUInteger row = [indexPath row];
cell.textLabel.text = [list objectAtIndex:row];
-(UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
return UITableViewCellEditingStyleN
-(BOOL) tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
return YES;
-(void) tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath
NSUInteger fromRow = [sourceIndexPath row];
NSUInteger toRow = [destinationIndexPath row];
id object = [[list objectAtIndex:fromRow] retain];
[list removeObjectAtIndex:fromRow];
[list insertObject:object atIndex:toRow];
[object release];
12. 在主程序中添加换行控件控制器的实例
//move cell
MoveMeController *moveMeConroller = [[MoveMeController alloc] initWithStyle:UITableViewStylePlain];
moveMeConroller.title=@&Move Me&;
moveMeConroller.rowImage =[UIImage imageNamed:@&moveMeIcon.png&];
[array addObject:moveMeConroller];
[moveMeConroller release];
编译,运行效果:
一级页面:
二级页面:
13.第五个子控制器-可删除的行
在启用表哥编辑模式后,可以对行进行移动调整,同样的可以可以对行进行删除。
依旧是建视图…
#import &SecondLevelViewController.h&
@interface DeleteMeController : SecondLevelViewController
@property (nonatomic,retain) NSMutableArray *
-(IBAction)toggleEdit:(id)
.m关键代码
-(IBAction)toggleEdit:(id)sender
[self.tableView setEditing:!self.tableView.editing animated:YES];
if(self.tableView.editing)
[self.navigationItem.rightBarButtonItem setTitle:@&Done&];
[self.navigationItem.rightBarButtonItem setTitle:@&Delete&];
- (void)viewDidLoad
if(list==nil)
NSString *path = [[NSBundle mainBundle]pathForResource:@&computers& ofType:@&plist&];
NSMutableArray *array = [[NSMutableArray alloc]initWithContentsOfFile:path];
self.list =
[array release];
UIBarButtonItem *editBtn = [[UIBarButtonItem alloc ]initWithTitle:@&Delete& style:UIBarButtonItemStyleBordered target:self action:@selector(toggleEdit:)];//这里多了个: 是因为这个切换方法多了一个sender
self.navigationItem.rightBarButtonItem = editB
[editBtn release];
[super viewDidLoad];
// Do any additional setup after loading the view.
-(NSInteger ) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
return [list count ];
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
static NSString *DeleteMeCellIdentifier = @&DeleteMeCekkIdentifier&;
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:DeleteMeCellIdentifier];
if(cell ==nil)
cell =[[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:DeleteMeCellIdentifier] autorelease];
NSInteger row = [indexPath row];
cell.textLabel.text = [self.list objectAtIndex:row];
-(void) tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
[self.list removeObjectAtIndex: [indexPath row]];
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];//最终指定动画 渐渐隐退
14.依旧是在1级控制器中添加删除行的子控制器
打开FirstLevelViewController.h在 viewDidLoad中添加代码
//Delete Me
DeleteMeController *deleteMeController = [[DeleteMeController alloc]initWithStyle:UITableViewStylePlain];
deleteMeController.title = @&Delete Me&;
deleteMeController.rowImage = [UIImage imageNamed:@&deleteMeIcon.png&];
[array addObject:deleteMeController];
[deleteMeController release];
self.controllers =
编译执行,效果如下:
子控制器页面
可编辑状态页面
按左边按钮之后出现的删除按钮
15.第六个子控制器-可编辑的详情页实现
15.1.由于详情页的字内容来自于一个归档好的文件,这里需要先建一个实现&NSCoding&的协议来操作这个文件。
President源码如下
#import &SecondLevelViewController.h&
#define kPresidentNumberKey @&President&
#define kPresidentNameKey @&Name&
#define kPresidentToKey @&ToYear&
#define kPresidentFromKey @&FromYear&
#define kPresidentPartyKey @&Party&
@interface President : NSObject
NSString *
NSString *fromY
NSString *toY
NSString *
@property (nonatomic,copy) NSString *
@property (nonatomic,copy) NSString *fromY
@property (nonatomic,copy) NSString *toY
@property (nonatomic,copy) NSString *
#import &President.h&
@interface President ()
@implementation President
@synthesize fromY
@synthesize toY
-(void) dealloc
[name release];
[fromYear release];
[toYear release];
[party release];
[super dealloc];
//把对象编码为归档文件
-(void)encodeWithCoder:(NSCoder *)coder
[coder encodeInt:self.number forKey:kPresidentNumberKey];
[coder encodeObject:self.name forKey:kPresidentNameKey];
[coder encodeObject:self.fromYear forKey:kPresidentFromKey];
[coder encodeObject:self.toYear forKey:kPresidentToKey];
[coder encodeObject:self.party forKey:kPresidentPartyKey];
//从归档文件创建出对象
-(id)initWithCoder:(NSCoder *)coder
if(self=[super init])
number =[coder decodeIntForKey:kPresidentNumberKey];
name = [[coder decodeObjectForKey:kPresidentNumberKey] retain];
fromYear = [[coder decodeObjectForKey:kPresidentFromKey] retain];
toYear = [[coder decodeObjectForKey:kPresidentToKey] retain];
party = [[coder decodeObjectForKey:kPresidentPartyKey] retain];
15.2.接下来创建视图列表
PresidentViewController
.h关键代码
#import &SecondLevelViewController.h&
@interface PresidentViewController : SecondLevelViewController
NSMutableArray *
@property (nonatomic,retain) NSMutableArray *
.m关键代码
- (void)viewDidLoad {
NSString *path = [[NSBundle mainBundle] pathForResource:@&Presidents&
ofType:@&plist&];
NSData * NSKeyedUnarchiver *
data = [[NSData alloc] initWithContentsOfFile:path];
unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:data]; NSMutableArray *array = [unarchiver decodeObjectForKey:@&Presidents&];
self.list =
[unarchiver finishDecoding];
[unarchiver release];
[data release];
[super viewDidLoad]; }
//父视图会重新加载数据
- (void)viewWillAppear:(BOOL)animated { [self.tableView reloadData];
[super viewWillAppear:animated];
- (void)dealloc {
[list release];
[super dealloc];
#pragma mark -
#pragma mark Table Data Source Methods
- (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section { return [list count];
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *) indexPath {
static NSString *PresidentListCellIdentifier = @&PresidentListCellIdentifier&;
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:PresidentListCellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:PresidentListCellIdentifier] autorelease];
NSUInteger row = [indexPath row];
President *thePres = [self.list objectAtIndex:row]; cell.textLabel.text = thePres.
cell.detailTextLabel.text = [NSString stringWithFormat:@&%@ - %@&,
thePres.fromYear, thePres.toYear];
#pragma mark -
#pragma mark Table Delegate Methods
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSUInteger row = [indexPath row];
President *prez = [self.list objectAtIndex:row];
PresidentDetailController *childController =
[[PresidentDetailController alloc] initWithStyle:UITableViewStyleGrouped];
childController.title = prez. childController.president =
[self.navigationController pushViewController:childController animated:YES];
[childController release];
15.3.视图详情页的视图
PresidentDetailController
.h文件详情 这里实现了一个TextField的委托它和tableView的数据源委托原理差不多
#import &UIKit/UIKit.h&
#define kNumberOfEditableRows 4
#define kNameRowIndex 0
#define kFromYearRowIndex 1
#define kToYearRowIndex 2
#define kPartyIndex 3
#define kLabelTag 4096
@interface PresidentDetailController : UITableViewController&UITextFieldDelegate&
President *
NSArray *fieldL NSMutableDictionary *tempV UITextField *textFieldBeingE
@property (nonatomic, retain) President *
@property (nonatomic, retain) NSArray *fieldL
@property (nonatomic, retain) NSMutableDictionary *tempV
@property (nonatomic, retain) UITextField *textFieldBeingE
- (IBAction)cancel:(id)
- (IBAction)save:(id)
- (IBAction)textFieldDone:(id)
.m文件关键代码
- (IBAction)cancel:(id)sender {
[self.navigationController popViewControllerAnimated:YES];
- (IBAction)save:(id)sender {
if (textFieldBeingEdited != nil) { NSNumber *tagAsNum= [[NSNumber alloc]
initWithInt:textFieldBeingEdited.tag]; [tempValues setObject:textFieldBeingEdited.text forKey: tagAsNum];
[tagAsNum release]; }
for (NSNumber *key in [tempValues allKeys]) { switch ([key intValue]) {
case kNameRowIndex:
president.name = [tempValues objectForKey:key];
case kFromYearRowIndex:
president.fromYear = [tempValues objectForKey:key];
case kToYearRowIndex:
president.toYear = [tempValues objectForKey:key];
case kPartyIndex:
president.party = [tempValues objectForKey:key]; default:
[self.navigationController popViewControllerAnimated:YES];
NSArray *allControllers = self.navigationController.viewC UITableViewController *parent = [allControllers lastObject]; [parent.tableView reloadData];
- (IBAction)textFieldDone:(id)sender { [sender resignFirstResponder];
#pragma mark -
- (void)viewDidLoad {
NSArray *array = [[NSArray alloc] initWithObjects:@&Name:&, @&From:&, @&To:&, @&Party:&, nil];
self.fieldLabels = [array release];
UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithTitle:@&Cancel&
style:UIBarButtonItemStylePlain target:self action:@selector(cancel:)];
self.navigationItem.leftBarButtonItem = cancelB [cancelButton release];
UIBarButtonItem *saveButton = [[UIBarButtonItem alloc] initWithTitle:@&Save&
style:UIBarButtonItemStyleDone target:self action:@selector(save:)];
self.navigationItem.rightBarButtonItem = saveB [saveButton release];
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init]; self.tempValues =
[dict release];
[super viewDidLoad];
- (void)dealloc {
[president release]; [fieldLabels release]; [tempValues release]; [textFieldBeingEdited release]; [super dealloc];
#pragma mark -
#pragma mark Table Data Source Methods
- (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section { return kNumberOfEditableR
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *PresidentCellIdentifier = @&PresidentCellIdentifier&;
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: PresidentCellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:PresidentCellIdentifier] autorelease]; UILabel *label = [[UILabel alloc] initWithFrame:
CGRectMake(10, 10, 75, 25)]; label.textAlignment = UITextAlignmentR
label.tag = kLabelT
label.font = [UIFont boldSystemFontOfSize:14]; [cell.contentView addSubview:label];
[label release];
UITextField *textField = [[UITextField alloc] initWithFrame: CGRectMake(90, 12, 200, 25)];
textField.clearsOnBeginEditing = NO; [textField setDelegate:self]; textField.returnKeyType = UIReturnKeyD [textField addTarget:self action:@selector(textFieldDone:) forControlEvents:UIControlEventEditingDidEndOnExit];
[cell.contentView addSubview:textField];
NSUInteger row = [indexPath row];
UILabel *label = (UILabel *)[cell viewWithTag:kLabelTag]; UITextField *textField =
for (UIView *oneView in cell.contentView.subviews) {
if ([oneView isMemberOfClass:[UITextField class]]) textField = (UITextField *)oneV
label.text = [fieldLabels objectAtIndex:row];
NSNumber *rowAsNum = [[NSNumber alloc] initWithInt:row];
switch (row) {
case kNameRowIndex:
if ([[tempValues allKeys] containsObject:rowAsNum])
textField.text = [tempValues objectForKey:rowAsNum];
textField.text = president.
case kFromYearRowIndex:
if ([[tempValues allKeys] containsObject:rowAsNum])
textField.text = [tempValues objectForKey:rowAsNum];
textField.text = president.fromY
case kToYearRowIndex:
if ([[tempValues allKeys] containsObject:rowAsNum])
textField.text = [tempValues objectForKey:rowAsNum];
textField.text = president.toY
case kPartyIndex:
if ([[tempValues allKeys] containsObject:rowAsNum])
textField.text = [tempValues objectForKey:rowAsNum];
textField.text = president. default:
if (textFieldBeingEdited == textField) { textFieldBeingEdited =
textField.tag = [rowAsNum release];
#pragma mark -
#pragma mark Table Delegate Methods
- (NSIndexPath *)tableView:(UITableView *)tableView
willSelectRowAtIndexPath:(NSIndexPath *)indexPath {
#pragma mark Text Field Delegate Methods
- (void)textFieldDidBeginEditing:(UITextField *)textField {
self.textFieldBeingEdited = textF }
- (void)textFieldDidEndEditing:(UITextField *)textField {
NSNumber *tagAsNum = [[NSNumber alloc] initWithInt:textField.tag]; [tempValues setObject:textField.text forKey:tagAsNum];
[tagAsNum release];
15.4.把视图列表添加到第二级的控制器中
在FristLevel下添加代码
// President View/Edit
PresidentViewController *presidentViewController =
[[PresidentViewController alloc]
initWithStyle:UITableViewStylePlain]; presidentViewController.title = @&Detail Edit&; presidentViewController.rowImage = [UIImage imageNamed:@&detailEditIcon.png&];
[array addObject:presidentViewController];
[presidentViewController release];
那么这样就把最后一个子控制器也添加进一级控制器了。
好啦,编码任务完成~~~
------------------------
-----------------------
在这个Nav的练习中学到很多关于导航控制器的东西,多视图应用离不开这个,所以回头还得多多研究下~
这里最后补充一个小小知识点:
已发表评论数()
&&登&&&陆&&
已收藏到推刊!
请填写推刊名
描述不能大于100个字符!
权限设置: 公开
仅自己可见}

我要回帖

更多关于 内盘和外盘是什么意思 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信