【发布时间】:2011-03-08 22:21:40
【问题描述】:
好的,我正在尝试向我的 tableview 添加一行。我一定做错了什么。我要添加到数组中,是否缺少使用新数组刷新 UITableView 的函数?
#import "RootViewController.h"
#import "DetailViewController.h"
@implementation RootViewController
@synthesize toolbar;
@synthesize window;
#pragma mark -
#pragma mark View lifecycle
- (void)viewDidLoad {
//theArray = [[NSArray alloc] initWithObjects:@"Apple",nil];
theArray = [[NSMutableArray alloc] init];
[super viewDidLoad];
[window addSubview:[navigationController view]];
[window addSubview:toolbar];
[window makeKeyAndVisible];
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
}
#pragma mark -
#pragma mark Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *selectedTask = [theArray objectAtIndex:indexPath.row];
DetailViewController *dvController = [[DetailViewController alloc] initWithNibName:@"DetailView" bundle:[NSBundle mainBundle]];
dvController.selectedTask = selectedTask;
[self.navigationController pushViewController:dvController animated:YES];
[dvController release];
dvController = nil;
}
- (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
非常感谢您的帮助,因为我环顾了该站点并看到了有关将数组推送到 tableview 的一些内容,但进一步的研究使我陷入了一场愚蠢的追逐。
【问题讨论】:
标签: iphone arrays ios uitableview sdk