【问题标题】:iOS Adding to UITableView using arrayiOS使用数组添加到UITableView
【发布时间】: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


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2012-03-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-26
      相关资源
      最近更新 更多