2015-01-15 19 views
1

我试图在我的视图中控制这样的手势识别器。检查UITextInteractionAssistant类

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer 
{ 
    NSMutableArray *targets = [gestureRecognizer valueForKeyPath:@"_targets"]; 
    id targetContainer = targets[0];//get first target for example 
    id targetOfMyGes = [targetContainer valueForKeyPath:@"_target"]; 

    NSMutableArray *targets1 = [otherGestureRecognizer valueForKeyPath:@"_targets"]; 
    id targetContainer1 = targets1[0];//get first target for example 
    id targetOfOtherGes = [targetContainer1 valueForKeyPath:@"_target"]; 

    if ([targetOfMyGes isKindOfClass:[UITextView class]] || [targetOfOtherGes isKindOfClass:[UITextView class]]) 
    { 

    } 

} 

当我调试时,targetOfOtherGes是这样的。

(lldb) po targetOfOtherGes 
<UITextInteractionAssistant: 0x194afdd0> 

我需要检查targetOfOtherGes是否是UITextInteractionAssistant的类。但是,当我检查时,我得到这样的错误。它说前向声明。所以,我需要导入.h文件。但是,我应该导入哪个文件?

enter image description here

回答

0

这是part of UIKit。如果它没有显示为有效,那么可能是因为Apple不希望您有权访问它。

这是一种janky的,但我做这样的事情围绕着类似的问题,得到了与UISegment

// the class definition in some header 
@interface FakeSegment : UIView 

@property (nonatomic, strong) id label; 

@end 

// how the fake definition can be used to get what you want 
NSString* typeName = NSStringFromClass([segment class]); 
if ([typeName isEqualToString:@"UISegment"]) { 
    UILabel *label = ((FakeSegment *)segment).label; 
}