2015-06-29 50 views
1

我在ios7(ipad)中遇到了问题,即导航栏和底部工具栏无法捕捉轻敲事件。相同的代码在ios 8(iphone/ipad)中工作正常。这里是我的代码,我有一个幻灯片,这是一个UIView,并且我推入另一个UIView singleCamView。第一次加载到singleCamView,导航和工具栏不起作用,但是当我回到slideView并再次进入singleCamView时,一切都很好。导航栏和底部工具栏不起作用(不响应点击/单击)

在slideView:

(void)viewDidAppear:(BOOL)animated { 
    [super viewDidAppear:animated]; 
    [self changeUILayout]; 
    [serverMgr disableTalkFunc]; 
    if (eLayoutType == eLayout_1X1 && !backFrom1x1) { 
     [self changeLayout_1x1]; 
    } 
} 

(void)changeLayout_1x1 { 
    if ([self.navigationController.visibleViewController isKindOfClass:[SlideView class]]) { 
     int camInArray = 0;//iPageIdx * [self getPreviewNum] + singleCamPos; 

     SinglePageViewController_Base *firstPage = [viewControllers objectAtIndex:0]; 
     SingleCamViewController * mCam = [[SingleCamViewController alloc] initWithServerManager:serverMgr CurrentCam:camInArray]; 
     [mCam setParent:firstPage]; 
     [mCam setTitle:[serverMgr getDeviceNameByChIndex:0]]; 
     mCam.changeLayoutDelegate = self; 
     int ch_index = 0;//iPageIdx * [self getPreviewNum] + pos; 
     [serverMgr updateAudioAndPtzDeviceByChIndex:ch_index]; 
     [mCam setPtzCap:[serverMgr isSupportPTZ:ch_index]]; 
     [mCam setAudioCap:[serverMgr isSupportAudio:ch_index]]; 
     [mCam setTalkCap:[serverMgr isSupportTalk:ch_index]]; 
     [firstPage setSingleCam:mCam]; 
     [serverMgr setPlaybackDelegate:mCam]; 
     [self.navigationController pushViewController:mCam animated:YES]; 
     //clear to default picture 
     [firstPage setDefaultPic]; 
     [serverMgr disconnectAllCam]; 
     [serverMgr connectToCamWithHighResolution:ch_index]; 
     [mCam release]; 

     eLayoutType = eLayout_1X1; 
     [serverMgr setLayoutType:eLayout_1X1]; 
     [parent save]; 
    } 
    else { 
     return; 
    } 
} 

在singleCamView:

.... 
UIImage *backImage; 
UIButton *bButton = [UIButton buttonWithType:UIButtonTypeCustom]; 
if (IS_IPAD) 
    backImage = [UIImage imageNamed:@"Back_48x48_nor.png"]; 
else 
    backImage = [UIImage imageNamed:@"Back_32x32_nor.png"]; 
bButton.bounds = CGRectMake(0, 0, backImage.size.width, backImage.size.height); 
[bButton setImage:backImage forState:UIControlStateNormal]; 
[bButton addTarget:self action:@selector(onBackBtnTap) forControlEvents:UIControlEventTouchUpInside]; 
UIBarButtonItem * backButton = [[UIBarButtonItem alloc] initWithCustomView:bButton]; 
UIBarButtonItem * backButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Back", nil) style:UIBarButtonItemStylePlain target:self action:@selector(onBackBtnTap)]; 
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0")) { 
    [backButton setTintColor:COLOR_NAVBUTTONTINT]; 
} 
else { 
    [backButton setTintColor:COLOR_NAVBUTTONTINTIOS6]; 
} 
self.navigationItem.leftBarButtonItem = backButton; 
[backButton release]; 

重要的是,它工作在iOS8上很好,我想不出原因。谢谢。

+1

视图高度宽度问题在ios 7 ...所以检查您的视图高度宽度 –

回答

0

最后我解决了我自己的问题,这里是解决方案,关键是第二个视图在主视图创建后立即被推入,控制器(可能)还没有完全初始化。所以我在主视图和第二视图之间添加了延迟,一切正常。

这篇文章给了我解决方案。 Adding delay between execution of two following lines