代码是exectuting但是当从函数调用时视图没有加载? [英] Code is exectuting but the view is not loading when called form a function?

查看:152
本文介绍了代码是exectuting但是当从函数调用时视图没有加载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用viewBased应用程序做一本书。 mainView充当用于加载页面的backgroundView。每个页面都是不同的视图,并有自己的笔尖。当我在页面上滑动时(实际上在加载了当前视图/页面的mainView上),该页面将被删除,并且将添加下一页/上一页。

I am doing a book kinda application using a viewBased application. The mainView acts as the backgroundView for loading pages. Each page is a different view and have its own nib. When i swipe on a page(actually on the mainView which have loaded the current view/page), that page will be removed and the next/previous page will be added.

[currentPage.view removeFromSuperview];
[self.view insertSubview:nextPage.view atIndex:0];

我在这个mainView中添加了一个带按钮的popoverController。它初始化了一个名为popClass的tableviewController类。 。PopClass是另一个类的UITableViewController将作为父的popViewController

I have added a popoverController with a barbutton in this mainView. Its intialized with a tableviewController class named popClass. PopClass is another UITableViewController class which will act as the parent for the popViewController.

self.myPopController = [[PopController alloc] initWithStyle:UITableViewStylePlain];
self.myPopOverController = [[UIPopoverController alloc] initWithContentViewController:myPopController];

当我在popover中选择某一行时,我希望backgroundview(mainView)加载相应的页面行数。

When I select certain row in the popover, I want the backgroundview(mainView) to load the page corresponding to the number of the row.

为此,我在bookView(mainView)Controller类中编写了一个函数。当我选择某一行时,从popOver的父类调用它。

For that I have written a function in bookView(mainView) Controller class. And is calling it from the popOver's parent class when i select certain row.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSInteger toPageNumber = indexPath.row + 1;
[viewController changeToPage:toPageNumber];
}

函数和代码行正在执行但没有任何事情发生。即使是日志行也会被打印,但不会发生任何动作。当我滑动视图/页面时,代码与删除页面和添加另一个成功的页面相同。

Function and the lines of code are executing but nothing is happening. Even the log lines are printed but no action takes place. The code is the same for removing a page and adding another page which is working successfully when i swipe the view/page.

有什么问题?还有其他方法可以通过使用popover在mainView中进行视图更改吗?

What is the problem? OR is there anyother way to make the view change in mainView by using the popover?

推荐答案

您需要参考背景在popover控制器中查看控制器。

You need to have refernce of the background view controller in the popover controller.

PopController 控制器中,您应该有一个类似于:

In the PopController controller you should have a delagate like:

@interface PopController: UITablViewController{

  //// other varibales;
      id delegate;
}

@property (nonatomic, retain) id delgate;

现在来自您展示popovercontroller的类

Now from the class in which you are showing the popovercontroller

你应该添加这一行:

[myPopController setDelegate:self];

然后您可以轻松访问主视图控制器类的任何方法。使用

Then you can easily acces any method of the main view controller class. By using

[delegate callTheRequiredMethod];

希望这会有所帮助。

谢谢,

Madhup

这篇关于代码是exectuting但是当从函数调用时视图没有加载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆