【问题标题】:The navigation bar and bottom toolbar is not working(not respond to tap/click)导航栏和底部工具栏不工作(不响应点击/点击)
【发布时间】:2015-09-15 19:37:29
【问题描述】:

我在ios7(ipad)有一个问题,就是导航栏和底部工具栏捕捉不到tap事件。相同的代码在 ios 8 (iphone/ipad) 中运行良好。这是我的代码,我有一个 UIView 的 slideView,我将另一个 UIView singleCamView 推入其中。我第一次加载到 singleCamView 时,导航和工具栏不起作用,但是当我回到 slideView 并再次进入 singleCamView 时,一切都很好。

在幻灯片视图中:

(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 中运行良好,我不知道原因。谢谢。

【问题讨论】:

  • ios 7 中的视图高度宽度问题...所以请检查您的视图高度宽度

标签: ios objective-c ipad uiview navigation


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-19
    相关资源
    最近更新 更多