搜尋此網誌

2012年6月18日 星期一

(IOS)tableView如何動態加載資料

//功能在tableView最下面加上new按下去會加載資料 
.h
@property(nonatomic, retain)
 NSMutableArray *ta1;
 ------------------------------------------------- .
m
- (void)viewDidLoad {
 ta1 =[[NSMutableArray alloc] initWithObjects:@"aaa",@"bbb",@"new", nil];
 [super viewDidLoad];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
 // VideoController *vc=[[VideoController alloc] initWithNibName:@"VideoController" bundle:nil];
 // [vc setTitle:[ta1 objectAtIndex:indexPath.row]];
 // [self.navigationController pushViewController:vc animated:YES];

 if ([[ta1 objectAtIndex:indexPath.row] isEqual:@"new"]) {
 [ta1 removeObject:@"new"];
 [ta1 addObject:@"pp1"];
 [ta1 addObject:@"pp2"];
 [ta1 addObject:@"pp3"];
 [ta1 addObject:@"new"];
 [self.tView reloadData]; }
 }