обновил мои файлы .h и .m. Как уже упоминалось, я должен получить данные (файл ) из таблицы ViewController1, когда строки (несколько) имеют , которые были выбраны для представления таблицы во втором контроллере представления. Здесь я в основном борьба со времен :)Как я передаю данные из SlideOut TableViewController в TableView, встроенный в ViewController
#import "ViewController1.h"
@interface UIViewController() <UITableViewDataSource, UITableViewDelegate> @end
@implementation ViewController1 {
NSArray *tableData; }
- (void)viewDidLoad {
[super viewDidLoad];
NSString *path = [[NSBundle mainBundle] pathForResource:@"TableData" ofType:@"plist"];
NSDictionary *dictionary = [[NSDictionary alloc] initWithContentsOfFile:path];
tableData = [dictionary objectForKey:@"Cupcakes"];}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated. }
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [tableData count]; }
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *simpleTableIdentifier = @"SimpleTableItem";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
}
cell.textLabel.text = [tableData objectAtIndex:indexPath.row];
cell.detailTextLabel.text = [tableData objectAtIndex:indexPath.row];
return cell;
}
@end
import "ViewController.h"
#import "SWRevealViewController.h"
@interface ViewController()
@end
@implementation ViewController
@synthesize count;
@synthesize countLabel;
@synthesize negative;
- (void)viewDidLoad
{
negative = TRUE;
[super viewDidLoad];
_barButton.target = self.revealViewController;
_barButton.action = @selector(revealToggle:);
[self.view addGestureRecognizer:self.revealViewController.panGestureRecognizer];
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
}
#pragma mark - TableView Deletage and Datasouce methods
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 10;
}
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
return YES;
}
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
}
}
- (IBAction)plus:(UIButton*)sender{
count++;
[self displayCount];
}
- (IBAction)minus:(UIButton*)sender {
count--;
if (negative){ //This simply checks if negative mode is offsw_rear
if (count < 0){ //and if count is negative
count = 0; //sets it back to zero
}}
[self displayCount];
}
- (void)displayCount {
[self.countLabel setText:[[NSString alloc]initWithFormat:@"%ld", (long)self.count]];
}
- (UIViewAnimationOptions) closeAnimationCurve {
return UIViewAnimationOptionCurveEaseOut;
}
// Enabling Deepnes on left menu
- (BOOL)deepnessForLeftMenu
{
return YES;
}
// Enabling Deepnes on left menu
- (BOOL)deepnessForRightMenu
{
return YES;
}
// Enabling darkness while left menu is opening
- (CGFloat)maxDarknessWhileLeftMenu
{
return 0.50;
}
// Enabling darkness while right menu is opening
- (CGFloat)maxDarknessWhileRightMenu
{
return 0.5;
}
@end
Комментарии для расширенного обсуждения; этот разговор был [перемещен в чат] (http://chat.stackoverflow.com/rooms/80466/discussion-on-answer-by-jenny-jose-how-i-pass-data-from-slideout-tableviewcontro) , – Taryn
, пожалуйста, примите этот ответ, если он работает! –