gpt4 book ai didi

ios - 越狱调整学习 - 带有 initWithFrame 的 UIViewController(单独文件) - 提供的代码

转载 作者:行者123 更新时间:2023-11-29 02:16:22 27 4
gpt4 key购买 nike

我正在学习如何创建越狱调整。

我希望这只是一个简单的问题。我正在使用 Theos。

我有以下设置:-

一个 View .h

#import <UIKit/UIKit.h>

@interface OneView : UIViewController

@end

=====================================

一个 View .m

#import "OneView.h"

@interface OneView ()

@end

@implementation OneView

- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self setOpaque:NO];
}
return self;
}

@end

=====================================

调整.xm

#import <UIKit/UIKit.h>
#include "OneView.h"

//这个函数可以正常工作和编译

%new
-(void)createView:() {
UIView *view11 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 480, 272)];
view11.backgroundColor = [UIColor redColor];
[self.view addSubview:view11];
}
%end

//这不起作用,它会在我编译时产生错误。

%new 
-(void)createOneView:() {
OneView *view11 = [[OneView alloc] initWithFrame:CGRectMake(0, 0, 480, 272)];
view11.backgroundColor = [UIColor redColor];
[self.view addSubview:view11];
}
%end

=====================================

错误

 Preprocessing Tweak.xm...
Compiling Tweak.xm...
Tweak.xm:144:44: error:

'OneView' may not respond to 'initWithFrame:' [-Werror]

OneView *view11 = [[OneView alloc] initWithFrame:CGRectMake(0, 0, 480,
272)];
~~~~~~~~~~~~~~~ ^
Tweak.xm:145:16: error: property 'backgroundColor' not found on object of type 'OneView *'
view11.backgroundColor = [UIColor redColor];
^
Tweak.xm:146:31: error: cannot initialize a parameter of type 'UIView *' with an lvalue of type 'OneView *'
[self.view addSubview:view11];

It does not like initWithFrame! is this something to do with headers !

谢谢

=========================

Error when inheriting UIView

bash-3.2# make package
Making all for tweak OneView...
Preprocessing Tweak.xm...
Compiling Tweak.xm...
Linking tweak OneCall...
Undefined symbols for architecture armv7:
"_OBJC_CLASS_$_OneCallView", referenced from:
objc-class-ref in Tweak.xm.249b7f24.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [obj/OneView.dylib.ba964c90.unsigned] Error 1
make[1]: *** [internal-library-all_] Error 2
make: *** [OneView.all.tweak.variables] Error 2

=========================

继承 UIViewController 时出错(更新)

        OneView *view11 = [[OneView alloc] initWithFrame:CGRectMake(0, 0, 480, 272)];  
view11.view.backgroundColor = [UIColor redColor];
[self.view addSubview:view11];

“OneView”可能不会响应“initWithFrame:”[-Werror]

        OneView *view11 = [[OneView alloc] initWithFrame:CGRectMake(0, 0, 480, 
272)];

最佳答案

您将 OneView 设为 UIViewController 的子类:

@interface OneView : UIViewController

但是你必须让它成为 UIView 的子类:

@interface OneView : UIView

关于ios - 越狱调整学习 - 带有 initWithFrame 的 UIViewController(单独文件) - 提供的代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28708242/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com