首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >视图复制?- ECSlidingViewController

视图复制?- ECSlidingViewController
EN

Stack Overflow用户
提问于 2013-09-20 08:58:49
回答 1查看 67关注 0票数 0

我目前正在使用ECSlidingViewController示例,在打开我当前所在的视图时出现了一个小错误。

看起来这些视图堆叠在一起。当我再次打开视图时,我需要一些方法来杀死这个类(视图)。

以下是单击-UItableView后会发生的情况

代码语言:javascript
复制
 NSLog(@"Channel 1 Loading");
        tableViewCellLoading = true;
        [self.slidingViewController anchorTopViewOffScreenTo:ECRight animations:nil onComplete:^{
            CGRect frame = self.slidingViewController.topViewController.view.frame;
            self.slidingViewController.topViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"firstChannel"];
            self.slidingViewController.topViewController.view.frame = frame;
            [self.slidingViewController resetTopView];
            [tableView deselectRowAtIndexPath:indexPath animated:YES]; }];

抽屉应用程序的外观

http://gyazo.com/f811283fadbad5b50ee4d594b6798f18

EN

回答 1

Stack Overflow用户

发布于 2014-07-28 15:48:57

我知道这个问题已经有一段时间了.但对于其他正在寻找的人来说,这里有一个答案。

以下代码来自我的"MenuController.m“文件。

代码语言:javascript
复制
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    self.slidingViewController.topViewController.view.layer.transform = CATransform3DMakeScale(1, 1, 1);
    UINavigationController *currentNav = (UINavigationController *)self.slidingViewController.topViewController;
    UIViewController *theControllerYouWant = [currentNav.viewControllers objectAtIndex:([currentNav.viewControllers count]-1)];
    NSString *CurrentSelectedCViewController = NSStringFromClass(theControllerYouWant.class);

    if (indexPath.row == 1 && ![CurrentSelectedCViewController isEqualToString:@"PeopleTableViewController"]) {
        [(UINavigationController *)self.slidingViewController.topViewController setViewControllers: [NSArray arrayWithObject: [self.storyboard instantiateViewControllerWithIdentifier:@"PeopleView"]]];
    } else if (indexPath.row == 2 && ![CurrentSelectedCViewController isEqualToString:@"CompanyPickerController"]) {
        [(UINavigationController *)self.slidingViewController.topViewController setViewControllers: [NSArray arrayWithObject: [self.storyboard instantiateViewControllerWithIdentifier:@"CompanyView"]]];
    }
    [self.slidingViewController resetTopViewAnimated:YES];
}

基本解释是这样的:

  1. 获取对当前导航控制器的引用
  2. 获取对导航控制器的顶视图(始终是其数组中的最后一个视图)的引用
  3. 获取该视图的字符串表示形式。
  4. 根据您单击的菜单单元格,检查slidingViewController的当前顶视图是否与您要转到的视图相同。如果与此不同,请在中加载适当的视图,以便使用topviewcontroller
  5. Close
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18907322

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档