我有兩個viewcontrollers都有tableviews。第一個視圖控制器在每一行中都有一個標題,而另一個空行。我想要的是能夠複製第一個視圖控制器中選定行的內容並將它們粘貼到第二個視圖控制器中的空行中。如何將選定的行從一個UITableView複製到另一個?
這裏是.m文件:
#import "SimpleTableViewController.h"
@interface SimpleTableViewController()
@end
@implementation SimpleTableViewController
{
NSArray *list;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
list = [NSArray arrayWithObjects:@"Pic 1", @"Pic 2", @"Pic 3", @"Pic 4", @"Pic 5", nil];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [list count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *simpleTableIndentifier= @"simpleTableCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIndentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIndentifier];
}
cell.textLabel.text = [list objectAtIndex:indexPath.row];
cell.imageView.image = [UIImage imageNamed:@"image.jpg"];
return cell;
}
@end
我是新來的UITableView所以我做這個學習的目的。
謝謝
在兩個數據源之間複製數據並重新加載。 – 2014-09-26 13:37:59