iphone - iOS使用数组添加到UITableView

标签 iphone arrays ios uitableview sdk

好的,我正在尝试在我的 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/

相关文章:

c - C 中的字符串结构变量赋值错误

java - 发送对同一类中另一个方法的引用的建议

ios - 将整数上传到 Firebase 数据库 IOS 的按钮

ios - 使用 Tapjoy Adob​​e AIR SDK

iphone - 在没有苹果开发者 ID 的设备上安装应用程序

ios - UIButton 不能横向工作

iphone - 参数和选择器

iphone - 使用自函数

ios - NSKeyedUnarchiver 无法处理在不同应用程序中创建的文件

javascript - 在除数数组中找到最小公约数