gpt4 book ai didi

iphone - IOS SDK 内 TableView 设置 Pane

转载 作者:行者123 更新时间:2023-11-28 23:17:42 25 4
gpt4 key购买 nike

我正在尝试编写一个基本的任务管理器,但是此时您只需选择该任务,它就会传递到另一个 Pane 以显示详细信息。如何使内部的 tableview 看起来像 native 设置应用程序?

> #import "RootViewController.h"
> #import "DetailViewController.h" @implementation RootViewController
> @synthesize toolbar; @synthesize
> window;
>
> #pragma mark -
> #pragma mark View lifecycle
>
>
>
> - (void)viewDidLoad { theArray = [[NSArray alloc]
> initWithObjects:@"Kill Taylor",@"Stab
> Taylor",@"Pay Jordan",nil];
> //theArray = [[NSMutableArray alloc]
> init];
>
>
> [super viewDidLoad];
>
> addButton = [[UIBarButtonItem alloc]
> initWithBarButtonSystemItem:UIBarButtonSystemItemAdd
> target:self
> action:@selector(addButtonPressed)];
> self.navigationItem.rightBarButtonItem
> = addButton; self.navigationItem.leftBarButtonItem
> = self.editButtonItem; //self.navigationItem.rightBarButtonItem
> = addButton; // self.navigationItem.rightBarButtonItem
> = addButton;
> // Uncomment the following line to display an Edit button in the
> navigation bar for this view
> controller.
> // self.navigationItem.rightBarButtonItem
> = self.editButtonItem; }
>
>
> -(void) addButtonPressed { NSString *selectedAction = @"add";
>
>
> DetailViewController *dvController =
> [[DetailViewController alloc]
> initWithNibName:@"DetailView"
> bundle:[NSBundle mainBundle]];
> dvController.selectedAction =
> selectedAction;
> //dvController.selectedTask =
> selectedTask;
> [self.navigationController
> pushViewController:dvController
> animated:YES]; [dvController
> release]; dvController = nil; }
>
>
> - (void)viewWillAppear:(BOOL)animated {
> [super viewWillAppear:animated]; }
>
> /*
> - (void)viewDidAppear:(BOOL)animated {
> [super viewDidAppear:animated]; }
> */ /*
> - (void)viewWillDisappear:(BOOL)animated
> { [super viewWillDisappear:animated];
> }
> */ /*
> - (void)viewDidDisappear:(BOOL)animated
> { [super viewDidDisappear:animated];
> }
> */
>
> /* // Override to allow orientations
> other than the default portrait
> orientation.
> - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
> { // Return YES for supported
> orientations. return
> (interfaceOrientation ==
> UIInterfaceOrientationPortrait); } */
>
>
>
> // Customize the number of sections in
> the table view.
> - (NSInteger)numberOfSectionsInTableView:(UITableView
> *)tableView {
> return 1; }
>
>
> // Customize the number of rows in the
> table view.
> - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
> { return [theArray count];
>
> }
>
>
>
> // Customize the appearance of table
> view cells.
> - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath
> *)indexPath {
>
> static NSString *CellIdentifier = @"Cell";
> UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
> if (cell == nil) {
> cell = [[[UITableViewCell alloc]
> initWithStyle:UITableViewCellStyleDefault
> reuseIdentifier:CellIdentifier]
> autorelease];
> }
>
> cell.textLabel.text = [theArray objectAtIndex:indexPath.row];
> return cell; }
> - (void)setEditing:(BOOL)editing animated:(BOOL)animated {
> if (editing)
> {
> // turn on the "add" button when editing
> //self.navigationItem.rightBarButtonItem
> = addButton;
> }
> else
> {
> // remove the "add" butto when not editing
> //self.navigationItem.rightBarButtonItem
> = nil;
> }
>
> [super setEditing:editing animated:animated]; }
>
>
> /* // Override to support conditional
> editing of the table view.
> - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath
> *)indexPath {
> // Return NO if you do not want the specified item to be editable.
> return YES; }
> */
>
>
> /* // Override to support editing the
> table view.
> - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
> forRowAtIndexPath:(NSIndexPath
> *)indexPath {
>
> if (editingStyle == UITableViewCellEditingStyleDelete) {
> // Delete the row from the data source.
> [tableView deleteRowsAtIndexPaths:[NSArray
> arrayWithObject:indexPath]
> withRowAnimation:UITableViewRowAnimationFade];
> }
> else if (editingStyle == UITableViewCellEditingStyleInsert) {
> // Create a new instance of the appropriate class, insert it into
> the array, and add a new row to the
> table view.
> } }
> */
>
>
> /* // Override to support rearranging
> the table view.
> - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath
> *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
> { }
> */
>
>
> /* // Override to support conditional
> rearranging of the table view.
> - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath
> *)indexPath {
> // Return NO if you do not want the item to be re-orderable.
> return YES; }
> */
>
>
> #pragma mark -
> #pragma mark Table view delegate
>
> - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
> *)indexPath { NSString *selectedAction = @"details"; NSString *selectedTask = [theArray
> objectAtIndex:indexPath.row];
> DetailViewController *dvController =
> [[DetailViewController alloc]
> initWithNibName:@"DetailView"
> bundle:[NSBundle mainBundle]];
> dvController.selectedAction =
> selectedAction;
> dvController.selectedTask =
> selectedTask;
> [self.navigationController
> pushViewController:dvController
> animated:YES]; [dvController
> release]; dvController = nil; }
>
>
> #pragma mark -
> #pragma mark Memory management
>
> - (void)didReceiveMemoryWarning {
> // Releases the view if it doesn't have a superview.
> [super didReceiveMemoryWarning];
>
> // Relinquish ownership any cached data, images, etc that aren't in use.
> }
>
> - (void)viewDidUnload {
> // Relinquish ownership of anything that can be recreated in
> viewDidLoad or on demand.
> // For example: self.myOutlet = nil; }
>
>
> - (void)dealloc {
> [super dealloc]; }
>
>
> @end

最佳答案

在界面构建器中选择表格 View 。然后去属性。应该有风格之类的东西。切换它,你就有了你梦想中的 tableview :-)

关于iphone - IOS SDK 内 TableView 设置 Pane ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5265763/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com