Instagram问题

设备ios 8.12
问题:tweak 代码执行到 [menuController setMenuVisible:YES animated:YES]; app会崩溃,不知道什么原因

1)开始怀疑是代码问题,寻找到可能是不是要求 设置 MenuItems 结尾为nil, 但修改代码下来还是不成功
[menuController setMenuItems:[NSArray arrayWithObjects: MenuItem,nil]];
2)网上搜索代码,好像代码没有问题3)搜索log 信息也没有搜到有用的东西
log:
an 24 00:50:56 Panda-iphone Instagram[6004]: longpress_begin
Jan 24 00:50:56 Panda-iphone Instagram[6004]: canBecomeFirstResponder
Jan 24 00:50:56 Panda-iphone Instagram[6004]: longpress_zhong1 <UIMenuItem: 0x167a2f30>
Jan 24 00:50:56 Panda-iphone Instagram[6004]: longpress_zhong2
Jan 24 00:50:56 Panda-iphone Instagram[6004]: longpress_zhong3 145 143
Jan 24 00:50:56 Panda-iphone mediaserverd[113]: ‘’ com.burbn.instagram(pid = 6004) setting DiscoveryMode = DiscoveryMode_None, currentDiscoveryMode = DiscoveryMode_None
Jan 24 00:50:56: — last message repeated 1 time —

THEOS_DEVICE_IP = 127.0.0.1
ARCH = armv7 arm64
TARGET = iPhone:8.1

include theos/makefiles/common.mk

TWEAK_NAME = Instagram
Instagram_FILES = Tweak.xm
Instagram_FRAMEWORKS = UIKit

include $(THEOS_MAKE_PATH)/tweak.mk

after-install::
    install.exec "killall -9 Instagram"
·······························

@class UILongPressGestureRecognizer;

@interface IGImageView : UIImageView
@end

@interface IGImageProgressView : UIView
@property(readonly, nonatomic) IGImageView *photoImageView; // @synthesize photoImageView=_photoImageView;
@end

@interface IGFeedItemPhotoView : UIView
@property(readonly, nonatomic) IGImageProgressView *photoImageView; // @synthesize photoImageView=_photoImageView;
@end

@interface IGFeedItemPhotoCell : UIView
@property(retain, nonatomic) IGFeedItemPhotoView *photoView; // @synthesize photoView=_photoView; 
@end

%hook IGFeedItemPhotoCell
- (id)initWithReuseIdentifier:(id)arg1
{
    id ret = %orig;
    {
        NSLog(@"initWithReuseIdentifier");
        UILongPressGestureRecognizer * gr = [UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longpress:)];
        [self addGestureRecognizer:gr];
        [gr release];
    }
    return ret;
}
%new//界面
-(void)longpress:(UILongPressGestureRecognizer*)gestureRecognizer
{
    if ([gestureRecognizer state] == UIGestureRecognizerStateBegan)
    {
        NSLog(@"longpress_begin");
        [gestureRecognizer view] becomeFirstResponder];//UIView inherits frtom UIResponder  Notifies the receiver that it’s about to become first responder in its NSWindow.
        CGPoint localtion = [gestureRecognizer locationInView:[gestureRecognizer view]];//Returns the point computed as the location in a given view of the gesture represented by the receiver.

        UIMenuController *menuController = [UIMenuController sharedMenuController];

        UIMenuItem * MenuItem = [UIMenuItem alloc] initWithTitle:@"Save" action:@selector(clickSave:)];

        NSLog(@"longpress_zhong1     %@",MenuItem);

        [menuController setMenuItems:[NSArray arrayWithObjects: MenuItem,nil]];

        NSLog(@"longpress_zhong2");
        //[menuController setTargetRect:CGRectMake(localtion.x,localtion.y-20,0.0f,0.0f) inView:[gestureRecognizer view]];
        [menuController setTargetRect:CGRectMake(localtion.x,localtion.y-20,0.0f,0.0f) inView:[gestureRecognizer view]];

        NSLog(@"longpress_zhong3 %d   %d",(int)(localtion.x),(int)(localtion.y-20));

        [menuController setMenuVisible:YES animated:YES];
         NSLog(@"longpress_zhong4");
        [MenuItem release];
        NSLog(@"longpress_end");
    }
}

%new
-(void)clickSave:(id)sender
{
    NSLog(@"clickSave_begin");
    if ([NSStringFromClass([self class]) isEqualToString:@"IGFeedItemPhotoCell"] == YES)
    {
        NSLog(@"sender = %@",sender);
        //IGFeedItemPhotoView *cell = (IGFeedItemPhotoView *)self;
        UIImage *image = [self photoView] photoImageView] photoImageView] image];
        UIImageWriteToSavedPhotosAlbum(image,nil,nil,nil);
    }
    NSLog(@"clickSave_end");
}
%new
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender//Requests the receiving responder to enable or disable the specified command in the user interface.
{
    NSLog(@"canPerformAction1 action = %@  withSender = %@",class_getInstanceMethod([self class],action),sender);

    if (action == @selector(clickSave:))
    {
        NSLog(@"canPerformAction2 action = %@  withSender = %@",class_getInstanceMethod([self class],action),sender);
        return YES;
    }
    NSLog(@"canPerformAction3 action = %@  withSender = %@",class_getInstanceMethod([self class],action),sender);
    return NO;
}
%new
- (BOOL)canBecomeFirstResponder//Returns a Boolean value indicating whether the receiver can become first responder.
{
    NSLog(@"canBecomeFirstResponder");
    return YES;
}
%end

syslog里,搜crash,看看有没有线索,这种调用函数后崩溃的情况,syslog里一般会有记录

大大 就是没有搜索到 crash 啊 ,没有能搜到什么有用的线索唯一 好像有用的 好像是
Jan 24 13:13:53 Panda-iphone mediaserverd[113]: ‘’ com.burbn.instagram(pid = 6267) setting DiscoveryMode = DiscoveryMode_None, currentDiscoveryMode = DiscoveryMode_None
但是GOOGLE 好像没有搜索到哎

Jan 24 13:13:45 Panda-iphone bird[360]: Network really becomes reachable
Jan 24 13:13:46 Panda-iphone Instagram[6267]:  INFO: Reveal server started.
Jan 24 13:13:46 Panda-iphone locationd[103]: Gesture EnabledForTopCLient: 0, EnabledInDaemonSettings: 0
Jan 24 13:13:47 Panda-iphone Instagram[6267]: initWithReuseIdentifier
Jan 24 13:13:48 Panda-iphone Instagram[6267]: Attempting to badge the application icon but haven't received permission from the user to badge the application
Jan 24 13:13:49 Panda-iphone Instagram[6267]:  SecTrustEvaluate  [leaf SSLHostname]
Jan 24 13:13:49 Panda-iphone Instagram[6267]: CFNetwork SSLHandshake failed (-9807)
Jan 24 13:13:50 Panda-iphone Instagram[6267]:  SecTrustEvaluate  [leaf SSLHostname]
Jan 24 13:13:50 Panda-iphone Instagram[6267]: CFNetwork SSLHandshake failed (-9807)
Jan 24 13:13:53 Panda-iphone Instagram[6267]: longpress_begin
Jan 24 13:13:53 Panda-iphone Instagram[6267]: canBecomeFirstResponder
Jan 24 13:13:53 Panda-iphone Instagram[6267]: longpress_zhong1     <UIMenuItem: 0x1674b6c0>
Jan 24 13:13:53 Panda-iphone Instagram[6267]: longpress_zhong2
Jan 24 13:13:53 Panda-iphone Instagram[6267]: longpress_zhong3 185   119
Jan 24 13:13:53 Panda-iphone mediaserverd[113]: '' com.burbn.instagram(pid = 6267) setting DiscoveryMode = DiscoveryMode_None, currentDiscoveryMode = DiscoveryMode_None
Jan 24 13:13:53: --- last message repeated 1 time ---
Jan 24 13:13:53 Panda-iphone com.apple.xpc.launchd[1] (UIKitApplication:com.burbn.instagram[0x286c][6267]): Service exited with abnormal code: 1
Jan 24 13:13:53 Panda-iphone SpringBoard[5949]: Application 'UIKitApplication:com.burbn.instagram[0x286c]' exited voluntarily.
Jan 24 13:13:53 Panda-iphone assertiond[57]: pid_suspend failed for <BKNewProcess: 0x14cd390c0; com.burbn.instagram; pid: 6267; hostpid: -1>: Unknown error: -1, Unknown error: -1
Jan 24 13:13:53 Panda-iphone assertiond[57]: Could not set priority of <BKNewProcess: 0x14cd390c0; com.burbn.instagram; pid: 6267; hostpid: -1> to 2, priority: No such process
Jan 24 13:13:53 Panda-iphone assertiond[57]: Could not set priority of <BKNewProcess: 0x14cd390c0; com.burbn.instagram; pid: 6267; hostpid: -1> to 4096, priority: No such process
Jan 24 13:13:53 Panda-iphone UserEventAgent[47]: id=com.burbn.instagram pid=6267, state=0
Jan 24 13:13:59 Panda-iphone iaptransportd[95]: CIapPortAppleIDBus: Auth timer timeout completed on pAIDBPort:0x136d1c140, portID:01 downstream port
Jan 24 13:13:59 Panda-iphone sshd[6275]: Accepted publickey for root from 127.0.0.1 port 51988 ssh2: RSA 2b:d8:a5:fd:86:4a:7c:7d:43:0d:4e:f0:7e:23:5a:98
Jan 24 13:13:59 Panda-iphone sshd: root@ttys000[6277]: USER_PROCESS: 6277 ttys000
Jan 24 13:14:00 Panda-iphone SCREEN[1060]: DEAD_PROCESS: 6277 ttys000
Jan 24 13:14:00 Panda-iphone SCREEN[1060]: USER_PROCESS: 1061 ttys002
Jan 24 13:14:01 Panda-iphone lockdownd[131]: 00484000 _select_socket: receive secure message timeout!
Jan 24 13:14:01 Panda-iphone lockdownd[131]: 00594000 _select_socket: receive secure message timeout!
Jan 24 13:14:02 Panda-iphone kernel[0]: 105505.638243 wlan0.A[5412] AppleBCMWLANNetManager::updateLinkQualityMetrics(): Report LQM to User Land 100, fAverageRSSI -65
Jan 24 13:14:06 Panda-iphone locationd[103]: Gesture EnabledForTopCLient: 0, EnabledInDaemonSettings: 0

我搜倒是有些结果,但没找到比较好的解决方案,你再google看看

在网上搜索了些答案好像都不起作用,似乎有很多出现 setting DiscoveryMode = DiscoveryMode_None 都好像不同的问题
大大 你有试过 IOS 8 并且 armv7 出现过这样的问题吗?
始终就是 这一句 出错了 [menuController setMenuVisible:YES animated:YES];
猜测是 对象不存在,但是打印出来还是有
不太明白就是这一句出错的,到这里 无法深入了

Jan 25 00:40:18 Panda-iphone locationd[103] : Gesture EnabledForTopCLient: 0, EnabledInDaemonSettings: 0
Jan 25 00:40:19 Panda-iphone Instagram[6631] : initWithReuseIdentifier
Jan 25 00:40:22 Panda-iphone Instagram[6631] : Attempting to badge the application icon but haven’t received permission from the user to badge the application
Jan 25 00:40:22 Panda-iphone Instagram[6631] : longpress_begin
Jan 25 00:40:22 Panda-iphone Instagram[6631] : canBecomeFirstResponder
Jan 25 00:40:22 Panda-iphone Instagram[6631] : longpress_zhong1 <UIMenuItem: 0x15f5bc10>
Jan 25 00:40:22 Panda-iphone Instagram[6631] : longpress_zhong2
Jan 25 00:40:22 Panda-iphone Instagram[6631] : longpress_zhong3 187 172
Jan 25 00:40:22 Panda-iphone mediaserverd[113] : ‘’ com.burbn.instagram(pid = 6631) setting DiscoveryMode = DiscoveryMode_None, currentDiscoveryMode = DiscoveryMode_None
Jan 25 00:40:22 Panda-iphone SpringBoard[5949] : Application ‘UIKitApplication:com.burbn.instagram[0x7e56]’ exited voluntarily.
Jan 25 00:40:22 Panda-iphone assertiond[57] : Could not set priority of <BKNewProcess: 0x14cd3b320; com.burbn.instagram; pid: 6631; hostpid: -1> to 4096, priority: No such process
Jan 25 00:40:22 Panda-iphone UserEventAgent[47] : id=com.burbn.instagram pid=6631, state=0
Jan 25 00:40:27 Panda-iphone locationd[103] : Gesture EnabledForTopCLient: 0, EnabledInDaemonSettings: 0
Jan 25 00:41:43 Panda-iphone locationd[103] : Gesture EnabledForTopCLient: 0, EnabledInDaemonSettings: 0
Jan 25 00:42:49 Panda-iphone locationd[103] : Gesture EnabledForTopCLient: 0, EnabledInDaemonSettings: 0
Jan 25 00:43:47 Panda-iphone kernel[0] : AppleARMPMUCharger: limiting USB input current to 900 mA (measured 661 mA)

这一句单独看起来是没问题的,而且书第二版的第9章,就用到了这个方法,也没问题。
我没有iOS 8,armv7的机子,只有armv7s的,是没问题的

终于发现问题了~~~~~~~~~~
NSLog(@“canPerformAction1 selector = %@ withSender = %@”,class_getInstanceMethod([self class],selector),sender);
这句代码有问题 所以就挂了 汗~~~
这里引发问题,就是 一些调试技巧问题 我重开一篇
http://bbs.iosre.com/t/topic/728
问题有点多,都是基础调试问题,希望大大不要介意问这么多