简体   繁体   English

对象不要称呼好的控制器

[英]Object don't call the good controller

In my apps, I have a toolBar with a button inside. 在我的应用程序中,我有一个工具栏,里面有一个按钮。 When you pressed that button a actionSheet appear and you can change the langage of the apps. 当您按下该按钮时,将显示一个actionSheet,您可以更改应用程序的语言。 I want a put this toolBar in a lot of view, but I want to use the same object, not copy-paste in all my view. 我希望将这个ToolBar放在很多视图中,但是我想使用同一对象,而不是在所有视图中都复制粘贴。 So I create a UIViewController with a nib file, this nib file containt my toolBar. 因此,我创建了一个带有nib文件的UIViewController,该nib文件包含我的toolBar。 Now, in a uiview, I do this 现在,在uiview中,我这样做

toolBar *objToolBall = [[toolBar alloc] initWithNibName:@"toolBar" bundle:nil];

objToolBall.view.frame = CGRectMake(0, 418, 320, 44);

[self.view addSubview:objToolBall.view];

[objToolBall release];

my problem is that when I pressed the button in the toolBar, the program try to find the method "clickButtonLanguage" in the file I create the object, and not in "toolBar.m". 我的问题是,当我按下ToolBar中的按钮时,程序尝试在我创建对象的文件中找到该方法“ clickButtonLanguage”,而不是在“ toolBar.m”中找到该方法。

How I can go in the "toolBar.m" method? 如何进入“ toolBar.m”方法?

The problem is not the release (assuming that your original viewController and its associated view are still around). 问题不在于发布(假设您的原始viewController及其关联的视图仍然存在)。 The release makes sense: you've created an object, handed off responsibility for it to the view you added it to, and now you need to release it so it doesn't leak. 该版本很有意义:您已经创建了一个对象,将对它的责任移交给了添加到它的视图,现在您需要释放它以免泄漏。 So don't drop that line. 因此,请勿删除该行。

You're getting the method invocation in your original view controller because that's exactly what you've connected it to . 您正在原始视图控制器中获得方法调用,因为这正是您将其连接到的对象 If you want to connect it to other IBActions you'll have to add them programmatically with 如果您想将其连接到其他IBActions ,则必须以编程方式添加它们

[objToolBall addTarget:action:forControlEvents:]

and then remove those objects as listeners with matching calls to -removeTarget:action:forControlEvents . 然后通过与-removeTarget:action:forControlEvents匹配调用将这些对象作为侦听器除去。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 UILabels在Landcsape模式下看起来不太好 - UILabels don't look good in the landcsape mode 如果AlertView,请不要在Xcode中弹出导航控制器 - Don't Pop Navigation Controller in Xcode if AlertView UITableView 不要重复使用电池,这样做的好案例吗? - UITableView don't reuse cells, good case to do this? 为什么不调用UIViewControllerTransitioningDelegate的方法presentationControllerForPresentedViewController? - Why don't call method presentationControllerForPresentedViewController of UIViewControllerTransitioningDelegate? 删除对象的CoreDataGeneratedAccessors似乎没有被删除 - CoreDataGeneratedAccessors to remove object don't seem to be deleting 无法从委托调用控制器方法 - Can't call controller method from delegate 第一次加载View Controller时,UIButton不能正确对齐 - UIButtons don't align correctly upon first load of View Controller 不要自动旋转视图控制器,而是显示UIAlertView旋转 - Don't autorotate view controller, but show UIAlertView rotated iPhone:获取结果控制器,不要在UITableView中使用部分 - iPhone: Fetched Results Controller, don't use sections in UITableView 不明白如何在iPhone中使用导航控制器 - don't understand how to use navigation controller in iphone
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM