@laomei wrote:
练习,创建了一个动态库Cocoa Touch Framework 如何添加一个button控件到运行界面呢?
DymicLib.h代码:#import <Foundation/Foundation.h> #import <UIKit/UIKit.h> @interface DymicLib : UIViewController @end
DymicLib.m代码
#import "DymicLib.h" #import <UIKit/UIKit.h> @implementation DymicLib static void __attribute__ ((constructor)) initialize (void) { NSLog(@"test1"); UIButton * btn = [[UIButton alloc] init]; btn.frame = CGRectMake(20, 20, 70, 30); btn.backgroundColor = [UIColor redColor]; [self.view addSubview:btn]; --此处报错self没有定义,我该如何修改,才能实现添加按钮成功呢?谢谢. } @end
我知道如果是一个普通Project,放到viewDidLoad中即可,但在动态库中,如何实现呢?
感谢各位老师!
Posts: 1
Participants: 1