gpt4 book ai didi

iphone - iOS使用数组添加到UITableView

转载 作者:行者123 更新时间:2023-12-01 19:28:10 25 4
gpt4 key购买 nike

好的,我正在尝试在我的 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 的一些内容,但进一步的研究使我陷入了一场愚蠢的追逐。

最佳答案

假设您拥有所有 UITableViewDataSource正确定义方法,您可能只需要在 UITableView 上调用 reloadData。见UITableView有关 reloadData 方法的详细信息,请参阅引用。

关于iphone - iOS使用数组添加到UITableView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5239096/

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