Присутствие от кнопки одного VC к другому VC делает SWrevealviewcontroller найденным ноль - PullRequest
0 голосов
/ 12 июня 2018

У меня проблема с SWRevealViewController Получение ноль ,
Пожалуйста, смотрите мое объяснение ниже.

Объяснение:

У меня есть 2 меню для моих 2 экранов View1 , View2 . View1 - это табличное представление, в котором я использовал настраиваемую ячейку, я добавил одну кнопку в настраиваемую ячейку.
Итак, когда я нажимаю на эту кнопку, она переходит к View2 , Но навигация по ползункам не работает.
Поскольку SWRevealViewController *revealViewController = self.revealViewController; получает ноль в View2

Вот мой код, который я написал в моем UITableViewCell class

UIViewController *view = [[[UIApplication sharedApplication] keyWindow] rootViewController];
 View2* mapviewController = [view.storyboard instantiateViewControllerWithIdentifier:@"MapView"];

[view presentViewController:mapviewController animated:NO completion:^{}];

Код, который я написал в моем View2

SWRevealViewController *revealViewController = self.revealViewController;
if ( revealViewController ) {
    [self.btnMenu setTarget: self.revealViewController];
    [self.btnMenu setAction: @selector( revealToggle: )];
    [self.view addGestureRecognizer:self.revealViewController.tapGestureRecognizer];
    self.revealViewController.rearViewRevealWidth = self.view.frame.size.width - 100;
}

Было бы здорово, если бы кто-то мог помочь мне решить эту проблему.

Заранее спасибо.
Михир Оза

Ответы [ 2 ]

0 голосов
/ 25 июня 2018

Поздний ответ,
С помощью Патрика я решаю эту проблему.

В моем контроллере табличного представления:

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    CustomTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CustomCell" forIndexPath:indexPath];

    // Configure the cell...
    cell.rvc = self.revealViewController;
    cell.title.text = @"Your title";

    return cell;
}  

В моей пользовательской ячейке:

    @interface CustomTableViewCell : UITableViewCell

    @property (nonatomic,strong) SWRevealViewController *rvc;
    @property (nonatomic,strong) IBOutlet UILabel *title;
    @property (nonatomic,strong) IBOutlet UIButton *button;

    @end  

    @implementation CustomTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    [self.button addTarget:self action:@selector(buttonTaped:) forControlEvents:UIControlEventTouchUpInside];
}

- (void)buttonTaped:(void *)sender {
    UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    UIViewController *vc = [sb instantiateViewControllerWithIdentifier:@"MapView"];
    [self.rvc pushFrontViewController:vc animated:YES];
}  

Ниже приведена полная ссылка, которая может быть полезна для кого-то:
Подарок от одного ВК другому

0 голосов
/ 12 июня 2018

Вы можете передать свою координату в методе tableViewDidSelectRow, как показано ниже:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

    MapViewController *objMapVC = [self.storyboard instantiateViewControllerWithIdentifier:@"MapViewController"];
    objMapVC.currentCord = CLLocationCoordinate2DMake(123.12345, 23.2345);
    [self presentViewController:objMapVC animated:YES completion:^{

    }];

}

или, если у вас есть кнопка в ячейке таблицы, назначьте индекс для вашей кнопки, как показано ниже:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    cell.yourButton.tag = row;
    return cell;
}

Теперь в вашем действии кнопки выполните следующие действия:

-(IBAction)btnMapClick:(UIButton *)sender{

    MapViewController *objMapVC = [self.storyboard instantiateViewControllerWithIdentifier:@"MapViewController"];
    objMapVC.currentCord = Array[sender.tag];
    [self presentViewController:objMapVC animated:YES completion:^{

    }];

}

Также определите одно свойство в вашем MapViewController, как показано ниже:

@interface MapViewController : UIViewController

@property (nonatomic) CLLocationCoordinate2D currentCord;

@end

Выполнив 2 шага выше, вы можете передать выбранный код.ордината к следующему MapVC.

...