2016-10-05 2 views
0

У меня проблема: главная страницаДобавление нового подвида в UIViewController из didSelectRowAtIndexPath прошивки 10

Моих IPad отделились на два видах.

1-я - меню (UITableView) (левая сторона);

2-я - рабочая область (UIViewController), где я изменяю UIView (правая сторона).

Приложение работает и выглядит как обычная социальная веб-страница.

AppDelegate.m

Прежде всего, я инициализировать мои UIViewControllers для рабочей зоны и добавить их в массив.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; 

    NSMutableArray *vcs = [NSMutableArray array]; 

    FriendsForImport *friendsForImport = [[CoreDataHelper helperCoreDataHelper] getSocialAccountInfoByIdSocial:0 withUid:@"myUid"]; 

    SocialPageViewController *socialPageViewController = [[SocialPageViewController alloc] initWithIdSocial:0 withFriendsForImport:friendsForImport withMyAccount:1]; 

    UINavigationController *socialPageNavigationController = [[UINavigationController alloc] initWithRootViewController:socialPageViewController]; 

    NSDictionary *socialPageNavigationControllerDict0 = [NSDictionary dictionaryWithObjectsAndKeys:socialPageNavigationController, @"vc", [NSString stringWithFormat:NSLocalizedString(@"MainMenuMyPageViewController", nil)], @"title", @"111-user.png", @"image", @"1", @"notification", @"0", @"idSocial",nil]; 

    [vcs addObject:socialPageNavigationControllerDict0]; 

     .....init and add to array another...... 

    Below In this method I init main UIViewController (**iPadSHSidebarViewController**) with UIViewControllers array. 

    _sidebariPad = [[iPadSHSidebarViewController alloc] initWithArrayOfVC:vcs]; 
      self.window.rootViewController = _sidebariPad; 
} 

В главном UIViewController iPadSHSidebarViewController.m

- (void)viewDidLoad 
{ 
    //init work area 
    _mainViewController = [[UIViewController alloc] init]; 

    //init menu 
    _menuView=[[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width*ksliderMenuWidthKoeff, self.view.frame.size.height)]; 
    [self.view addSubview:_menuView]; 
     ..... 
    //set to work area first UIViewController from array (SocialPageViewController) 
    [self changeMain:[[viewsArray objectAtIndex:0] objectForKey:@"vc"]]; 
} 

// for changing UIViewControllers in work area 
-(void)changeMain:(UIViewController *)main 
{ 
    [_mainViewController.view removeFromSuperview]; 
    _mainViewController = main; 
    _mainViewController.view.frame=CGRectMake(_menuView.frame.size.width, 0, self.view.frame.size.width-_menuView.frame.size.width, self.view.frame.size.height); 
    [self.view addSubview:_mainViewController.view]; 
} 

// for opening selected user's page UIViewControllers in work area above all opened UIViewControllers 

-(void)setModalInMain:(UIViewController *)modal 
{ 
    modal.view.tag=countTag++; 
    [_mainViewController.view addSubview:modal.view]; 
} 

SocialPageViewController является страница пользователя и первое, что мы видим в рабочей области, когда приложение инициализации.

SocialPageViewController получил UIViewTable с списком друзей. Когда пользователь нажимает на строку в списке друзей, запустите новый UIViewControler с данными выбранного пользователя, используя метод UIViewControler (iPadSHSidebarViewController) в рабочей области setModalInMain.

SocialPageViewController.m

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    FriendsForImport *friendsForImport = [_listArrayForOut objectAtIndex:indexPath.row]; 

    if([friendsForImport.active intValue]==1){ 

     SocialPageViewController *socialPageViewController = [[SocialPageViewController alloc] initWithIdSocial:_idSocial withFriendsForImport:friendsForImport withMyAccount:0]; 
     socialPageViewController.delegate=self; 
     UINavigationController *socialPageNavigationController = [[UINavigationController alloc] initWithRootViewController:socialPageViewController]; 

     iPadSHSidebarViewController *ipadSHSidebarViewController=(iPadSHSidebarViewController*)XAppDelegate.window.rootViewController; 
     [ipadSHSidebarViewController setModalInMain: socialPageNavigationController]; 
    } 
} 

В iPhone (iOS8,10) все работает отлично.

В IPAD (iOS8) все работает отлично

Скриншот # 1

Но в IOS 10 - когда я нажимаю на строку, вместо страницы данных пользователя, открывает пустой UIViewController с белой навигационной панелью.

(Но если в IOS 10 я попытаюсь сделать это в других местах (коснитесь кнопки на панели навигации) - все работает нормально).

Скриншот # 2

Если я попробовать открыть страницу с didSelectRowAtIndexPath без Панель навигации - все отлично работает. Но страница открыта без навигационной панели.

Скриншот # 3

Почему это произошло в iOS10 и только в методе didSelectRowAtIndexPath?

If I try open page from didSelectRowAtIndexPath without navigationbar - all work fine. But page open without navigationbar.

First what user see in work area when app init is **SocialPageViewController**.

in iOS 10 - when I tap to the row, instead of user's data page, opens the empty UIViewController with white navigation bar

ответ

0

На этот раз я найти решение, добавив задержку перед addSubView

double delayInSeconds = 0.1; 
    dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)); 
    dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ 
     [ipadSHSidebarViewController setModalInMain: socialPageNavigationController]; 
    }); 
Смежные вопросы