Ios 行动表关闭时ShareKit失去焦点
我正在尝试将ShareKit集成到我的ios游戏中 一切正常,显示了操作表,我可以与之交互,但当sharekit操作结束时,我无法通过关闭操作表或完成任何操作将焦点返回到我的应用程序 我试过几种方法,但任何一种都对我有效。发生了什么事? 我不是一个专业的程序员,所以我想我错过了一些东西 我是 这是我的Ios 行动表关闭时ShareKit失去焦点,ios,view,focus,sharekit,Ios,View,Focus,Sharekit,我正在尝试将ShareKit集成到我的ios游戏中 一切正常,显示了操作表,我可以与之交互,但当sharekit操作结束时,我无法通过关闭操作表或完成任何操作将焦点返回到我的应用程序 我试过几种方法,但任何一种都对我有效。发生了什么事? 我不是一个专业的程序员,所以我想我错过了一些东西 我是 这是我的 #import <UIKit/UIKit.h> #import "SHK.h" #import "SHKConfiguration.h" @interface SocialWrapp
#import <UIKit/UIKit.h>
#import "SHK.h"
#import "SHKConfiguration.h"
@interface SocialWrapper: UIViewController{
}
- (id) init;
- (void) open;
- (void) dealloc;
@end
我用这个包装器来称呼它
#import "SocializeWrapper.h"
SocialWrapper *socialize;
void SHKinit(void) {
NSLog(@"SHK Init");
socialize = [[SocialWrapper alloc] init];
}
void SHKopenWeb(void){
NSLog(@"SHK Open actionsheet");
[socialize open];
}
我正在使用ios 5、xcode 4.3.2和git的最新sharekit版本
我想一旦行动单关闭,我就必须解开我的社交包装,但我不知道如何捕捉那个事件,甚至不知道这是否正确。我累坏了
任何帮助都将不胜感激
使现代化
如评论所述,现在控制器位于一个类别上,使用actionsheet委托,单击cancel的actionsheet按钮可以重新获得焦点。当操作完成或取消时,问题仍然存在。不知道如何捕捉那个事件
这是我的分类代码:
#import "SocialWrapper.h"
@implementation UIViewController (SocialController)
-(void) loadconfig
{
DefaultSHKConfigurator *configurator = [[DefaultSHKConfigurator alloc] init];
[SHKConfiguration sharedInstanceWithConfigurator:configurator];
[SHK flushOfflineQueue];
}
- (void) open
{
NSLog(@"Opening social button");
NSString *someText = @"Monkey Armada rules!";
SHKItem *item = [SHKItem text:someText];
// Get the ShareKit action sheet
SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:item];
UIWindow *window = [UIApplication sharedApplication].keyWindow;
[window addSubview:self.view];
[actionSheet setDelegate:self];
[SHK setRootViewController:self];
[actionSheet showInView:self.view];
}
- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex
{
NSLog(@"SHK actionsheet dissmiss with button %d", buttonIndex);
if(buttonIndex == 4)
{
NSLog(@"SHK close actionsheet");
[self dismissViewControllerAnimated:YES completion:nil];
[self.view removeFromSuperview];
}
}
@end
因为ShkaActionSheet是UIActionSheet的一个子类,所以可以将该类的委托设置为self,以便知道何时发生解雇 还有,[自我释放];在dealloc中,完全误解了release的功能,如果你在dealloc中,那么release self不会做任何事情! 学习内存管理规则
我还应该警告您,[window addSubview:self.view]已被弃用,您根本不应该这样做。事实上,我不认为有理由包装共享工具包,因为每个视图控制器都应该能够轻松编写这些代码。更糟糕的是,如果您不想每次都重写代码,您可以将代码放在UIViewController上的一个类别中。您好,我已经按照您的建议进行了操作,现在代码已经在一个类别中了。现在,操作表已经很好地关闭,使用操作表委托重新获得焦点。现在,只有在完成推特/邮件发送或取消等操作时,问题才会继续存在。。。我想我必须删除视图才能获得焦点,但不知道在哪里以及如何做,可能是捕获动作完成/取消的事件?你有没有想过?我也有同样的问题:从UIActionSheet popover关闭可以正常工作,但是通过取消或成功完成来完成一个操作并没有任何作用。
#import "SocialWrapper.h"
@implementation UIViewController (SocialController)
-(void) loadconfig
{
DefaultSHKConfigurator *configurator = [[DefaultSHKConfigurator alloc] init];
[SHKConfiguration sharedInstanceWithConfigurator:configurator];
[SHK flushOfflineQueue];
}
- (void) open
{
NSLog(@"Opening social button");
NSString *someText = @"Monkey Armada rules!";
SHKItem *item = [SHKItem text:someText];
// Get the ShareKit action sheet
SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:item];
UIWindow *window = [UIApplication sharedApplication].keyWindow;
[window addSubview:self.view];
[actionSheet setDelegate:self];
[SHK setRootViewController:self];
[actionSheet showInView:self.view];
}
- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex
{
NSLog(@"SHK actionsheet dissmiss with button %d", buttonIndex);
if(buttonIndex == 4)
{
NSLog(@"SHK close actionsheet");
[self dismissViewControllerAnimated:YES completion:nil];
[self.view removeFromSuperview];
}
}
@end