【问题标题】:iOS - UIButton does not appear on UIViewiOS - UIButton 不会出现在 UIView 上
【发布时间】:2013-05-18 14:51:54
【问题描述】:

这个调整应该用一个视图覆盖锁屏(确实会发生)并向视图添加一个“iOS”按钮(不会发生)。这是我的代码:

#import <UIKit/UIKit.h>
#import <SpringBoard/SpringBoard.h>

@interface Themos
-(void)unlock;
@end

%hook SpringBoard
-(void)applicationDidFinishLaunching:(id)application
{
    %orig;

    UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(10,10,80,30)];
    [button addTarget:self action:@selector(unlock:) forControlEvents:UIControlEventTouchUpInside];
    [button setTitle:@"iOS" forState: UIControlStateNormal];

    UIWindow* window = [UIApplication sharedApplication].keyWindow;
    UIView *polygonView = [[UIView alloc] initWithFrame: CGRectMake ( 0, 0, 640, 960)];
    polygonView.backgroundColor = [UIColor redColor];
    [window addSubview:polygonView];
    [polygonView addSubview:button];
    [window makeKeyAndVisible];
    [polygonView release];
    [button release];
}

%new(v@:)
-(void)unlock
{
    [self unlockWithSound:YES];
}
%end

提前致谢! :)

【问题讨论】:

    标签: ios uiview uibutton tweak theos


    【解决方案1】:

    在窗口可见后添加子视图到窗口。

    在这行代码之后添加子视图然后它就会出现。

    [window makeKeyAndVisible];
    
    
    -(void)applicationDidFinishLaunching:(id)application
    {
        %orig;
    
        UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(10,10,80,30)];
        [button addTarget:self action:@selector(unlock:) forControlEvents:UIControlEventTouchUpInside];
        [button setTitle:@"iOS" forState: UIControlStateNormal];
    
        UIWindow* window = [UIApplication sharedApplication].keyWindow;
        [window makeKeyAndVisible];
        UIView *polygonView = [[UIView alloc] initWithFrame: CGRectMake ( 0, 0, 640, 960)];
        polygonView.backgroundColor = [UIColor redColor];
        [window addSubview:polygonView];
        [polygonView addSubview:button];
        [polygonView release];
        [button release];
    }
    

    【讨论】:

    • @Nick Aliferopoulos:现在来了吗?
    • 非常感谢!有效! :) 现在我因为解锁设备的方式而崩溃了。你碰巧知道其他方法吗?
    • 从中删除(解锁:)冒号并检查 it.place like (unlock)this.
    • @Nick Aliferopoulos:发生了什么?
    猜你喜欢
    • 1970-01-01
    • 2014-08-12
    • 2013-04-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-07
    相关资源
    最近更新 更多