【发布时间】:2011-03-07 17:13:44
【问题描述】:
我正在使用一个库,它是一个继承自 UIView 的类。如何以编程方式创建使用此类的 UIViewController,而不是普通的 UIView?
ViewController 的 .h 文件如下所示:
#import <UIKit/UIKit.h>
#import "PLView.h"
@interface HelloPanoramaViewController : UIViewController {
IBOutlet PLView * plView;
}
@property (nonatomic, retain) IBOutlet PLView *plView;
@end
.m文件如下:
#import "HelloPanoramaViewController.h"
@implementation HelloPanoramaViewController
@synthesize plView;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do stuff here...
}
- (void)dealloc
{
[plView release];
[super dealloc];
}
@end
然后我应该使用笔尖让“plView 变量指向视图”。 但是如果不使用 Interface Builder,我将如何以编程方式执行此操作?我怎么能让这个 UIViewController 创建一个 PLView,而不是 UIView?
【问题讨论】:
-
仅供参考,如果您不知道,您实际上也可以执行此 IB,方法是将 nib 中主 UIView 的“类”属性更改为所需的类名。跨度>
标签: iphone uiview uiviewcontroller