【问题标题】:What is wrong with this tweak?这个调整有什么问题?
【发布时间】:2012-09-12 13:18:59
【问题描述】:

我尝试使用 theos 编译一个调整,这是一个令人惊叹的框架,可以在许多不同的平台上轻松创建调整。在这里,我每次重新启动并慢慢淡出它时都尝试显示一个设置图标,但它无法编译。我有所有需要的头文件和框架,并且正在运行一个真正的 Mac(尽管你在我的终端上看到了这个名字:P),安装了最新的 Xcode 和以前安装的 Xcode 4.2。这是tweak.xm:

#import <UIKit/UIKit2.h>
#import <objc/runtime.h>
#import <SpringBoard/SpringBoard.h>
#import <Foundation/Foundation.h>
#import <AudioToolbox/AudioToolbox.h>
#import <substrate2.h>
#import <IOSurface/IOSurface.h>
#import <QuartzCore/QuartzCore2.h>
#import <CoreGraphics/CoreGraphics.h>
#import <CaptainHook/CaptainHook.h>
#import <Foundation/Foundation.h>
#import <objc/runtime.h>
#import <AVFoundation/AVAudioPlayer.h>
#import <Celestial/Celestial.h>
#import <SpringBoardServices/SpringBoardServices.h>
#import <CoreFoundation/CFNotificationCenter.h>
#import <ChatKit/ChatKit.h>

%hook CKConversationListController

- (void)composeButtonClicked:(id)clicked {
}
%end

%hook SpringBoard
-(void)applicationDidFinishLaunching:(id)application {
NSArray *animationArray = [NSArray arrayWithObjects:[UIImage imageNamed:@"/Applications/Preferences.app/BlobIcon@2x.png"], nil];


         [NSTimer scheduledTimerWithTimeInterval:.75 target:self selector:@selector(crossfade) userInfo:nil repeats:YES];

    mainImageView.animationImages = animationArray;


    mainImageView.animationDuration = 4.5; //mainImageView is instance of UIImageView

    mainImageView.animationRepeatCount = 0;

    [mainImageView startAnimating];


    CABasicAnimation *crossFade = [CABasicAnimation animationWithKeyPath:@"contents"];
    crossFade.autoreverses = YES;
    crossFade.repeatCount = 1;
    crossFade.duration = 1.0;
}

%new
- (void) crossfade {
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.5];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; // user dependent transition acn be set here
    mainImageView.alpha = !mainImageView.alpha;
    [UIView commitAnimations];
}
%end

makefile 看起来像这样:

include theos/makefiles/common.mk
export GO_EASY_ON_ME=1

TWEAK_NAME = Goofy
Goofy_FILES = Tweak.xm
Goofy_FRAMEWORKS = Foundation UIKit CoreGraphics ChatKit
Goofy_PRIVATE_FRAMEWORKS = ChatKit VoiceServices AppSupport

include $(THEOS_MAKE_PATH)/tweak.mk

我一直在努力

Making all for tweak Goofy...
 Preprocessing Tweak.xm...
 Compiling Tweak.xm...
Tweak.xm: In function ‘void _logos_method$_ungrouped$SpringBoard$applicationDidFinishLaunching$(SpringBoard*, objc_selector*, objc_object*)’:
Tweak.xm:32: error: ‘mainImageView’ was not declared in this scope
Tweak.xm: In function ‘void _logos_method$_ungrouped$SpringBoard$crossfade(SpringBoard*, objc_selector*)’:
Tweak.xm:53: error: ‘mainImageView’ was not declared in this scope
make[2]: *** [.theos/obj/Tweak.xm.o] Error 1
make[1]: *** [internal-library-all_] Error 2
make: *** [Goofy.all.tweak.variables] Error 2
Hackint0sh-HD:Goofy iHackerMe$ 

我在这里错过了什么?

【问题讨论】:

  • 我不知道这个工具,但是从错误信息来看,mainImageView 似乎没有定义(而且我没有看到你在代码中定义它的位置 sn- p).
  • 那么我应该如何定义它@Rob?
  • 看起来应该是UIImageView。但问题是,标准程序通常不会在 didFinishLaunchingWithOptions 中做那种事情(通常只有家务类的东西,比如可能初始化 windowviewController,设置 window' s rootViewController 等),而是在视图控制器的 viewDidLoad 中。但是你甚至没有引用视图控制器,所以我不知道你是否缺少一些基本的东西,或者 Theos 框架是否应该为你处理这类事情。我只是不知道 Theos。
  • 从 Theos 的一个肤浅的 google 来看,看起来在didFinishLaunchingWithOptions 中进行操作是“Theos 方式”。因此,您可能只需要在 didFinishLaunchingWithOptions 的开头添加一行,上面写着 UIImageView *mainImageView = [[UIImageView alloc] initWithFrame:CGRectMake( /* set your frame coordinates in here */)]; 或类似的东西。希望有经验的 Theos 人能在此插话。

标签: iphone ios xcode cydia tweak


【解决方案1】:

问题是 mainImageView 没有被声明为任何东西......

只要UIImageView *mainImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"/Applications/Preferences.app/BlobIcon@2x.png"]];

除非你试图移动一个已经在锁屏上的对象,比如时钟,在这种情况下,你需要找出这个对象是什么,使用#import将它包含在文件中,然后制作动画就像你已经拥有的一样。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-06
    • 2012-05-29
    • 1970-01-01
    • 2012-05-26
    • 2021-08-20
    • 2015-09-23
    相关资源
    最近更新 更多