objective-c – 以模态方式呈现视图控制器 – iPad

objective-c – 以模态方式呈现视图控制器 – iPad,第1张

概述我发现这段代码显示了一个模态视图: - (void)add:(id)sender { // Create the root view controller for the navigation controller // The new view controller configures a Cancel and Done button for the // navigatio 我发现这段代码显示了一个模态视图:

- (voID)add:(ID)sender {   // Create the root vIEw controller for the navigation controller   // The new vIEw controller configures a Cancel and Done button for the   // navigation bar.   RecipeAddVIEwController *addController = [[RecipeAddVIEwController alloc]                       initWithNibname:@"RecipeAddVIEw" bundle:nil];   addController.delegate = self;   // Create the navigation controller and present it modally.   UINavigationController *navigationController = [[UINavigationController alloc]                             initWithRootVIEwController:addController];   [self presentModalVIEwController:navigationController animated:YES];   // The navigation controller is Now owned by the current vIEw controller   // and the root vIEw controller is owned by the navigation controller,// so both objects should be released to prevent over-retention.   [navigationController release];   [addController release];}

我的问题是如何实现此代码(我将把它放在buttonPress方法中)

我需要在头文件中定义任何内容吗?令我困惑的是,apple on提供了这个并且没有头文件,所以我不知道是否应该有什么?

代码引用了RecipIEAddVIEwController,我还能用“UIVIEwController”来解决这个问题?

我在头文件中作为委​​托放了什么?我需要在其他地方设置吗?喜欢财产?

一旦我在buttonPress方法中复制此代码以使其工作,我还需要做些什么吗?

感谢并抱歉所有问题.

解决方法

My question is how do I implement this code (I’m going to place it in a buttonPress method)

将方法定义为IBAction,如 – (IBAction)add:(ID)sender并在界面构建器中将按钮的内部事件绑定到视图控制器对象的add:action outlet.

Do I need to define anything in my header file? The bit that confuses me is that apple on provIDes this and no header file so i cant tell if anything should be there?

不.所有这些东西需要的是UIKit.h您通常需要更改标头以添加方法,添加实例变量或包含自定义类.但是,您可能需要在某处(在标题或实现文件中)使用#import RecipeAddVIEwController.h才能使用该类.对于要在另一个文件中使用的任何自定义类,都是如此.

The code refers to RecipIEAddVIEwController what do I repleace this with,“UIVIEwController”?

将其替换为要推送的视图控制器类. UIVIEwController本身很少有用.它是为子类化的.因此,您创建一个继承自UIVIEwController的新类,导入它的标题,创建它的实例,并将其推送到导航控制器上.

总结

以上是内存溢出为你收集整理的objective-c – 以模态方式呈现视图控制器 – iPad全部内容,希望文章能够帮你解决objective-c – 以模态方式呈现视图控制器 – iPad所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1009826.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存