我在我的 UIViewController 中使用了这个函数
void showMap()
{
}
如果我使用objective-c 函数,我可以调用self.view
,但是如何在UIViewContoller 内的C 函数中调用它?
(我需要self.view = myObject
在 C 函数内部使用,当我尝试使用self.view = myObject
xcode 时说没有变量self
)
更新:
我需要这个在 Unity 3d 中使用
我在我的 UIViewController 中使用了这个函数
void showMap()
{
}
如果我使用objective-c 函数,我可以调用self.view
,但是如何在UIViewContoller 内的C 函数中调用它?
(我需要self.view = myObject
在 C 函数内部使用,当我尝试使用self.view = myObject
xcode 时说没有变量self
)
更新:
我需要这个在 Unity 3d 中使用
In . m file
for example In LoginPage.m
#import "LoginPage.h"
LoginPage *loginP;
@interface LoginPage ()
@end
@implementation LoginPage
- (void)viewDidLoad
{
[super viewDidLoad];
self.title=@"Login";
self.navigationController.navigationBar.tintColor = [UIColor blackColor];
loginP = self; //assign self to loginP
}
void showMap()
{
UIView *view = [[UIView alloc ]initWithFrame:CGRectMake(0, 10, 50, 100)];
[loginP.view addSubview:view];
//Now you can use self inside c function ..and access any method of class
}
我找到了解决方案
void showMap(UIViewController *self)
{
self.view = newView;
}