XSLT存档  

不及格的程序员-八神

 查看分类:  ASP.NET XML/XSLT JavaScripT   我的MSN空间Blog

Today, i had trying update my project with three20 to ios6, but somethings had raised that it reports errors (e.g. _tapCount,_view can not by finded) in file UIViewAdditions.m.

 打开文件后发现里面有宏定义,判断如果是调试阶段,会使用 私有变量 输出某些信息,结果屏避之再编译就可以了。

  1 / Remove GSEvent and UITouchAdditions from Release builds
  2 #ifdef DEBUG
  3 
  4 ///////////////////////////////////////////////////////////////////////////////////////////////////
  5 ///////////////////////////////////////////////////////////////////////////////////////////////////
  6 ///////////////////////////////////////////////////////////////////////////////////////////////////
  7 /**
  8  * A private API class used for synthesizing touch events. This class is compiled out of release
  9  * builds.
 10  *
 11  * This code for synthesizing touch events is derived from:
 12  * http://cocoawithlove.com/2008/10/synthesizing-touch-event-on-iphone.html
 13  */
 14 @interface GSEventFake : NSObject {
 15   @public
 16   int ignored1[5];
 17   float x;
 18   float y;
 19   int ignored2[24];
 20 }
 21 @end
 22 
 23 
 24 ///////////////////////////////////////////////////////////////////////////////////////////////////
 25 ///////////////////////////////////////////////////////////////////////////////////////////////////
 26 ///////////////////////////////////////////////////////////////////////////////////////////////////
 27 @implementation GSEventFake
 28 @end
 29 
 30 
 31 ///////////////////////////////////////////////////////////////////////////////////////////////////
 32 ///////////////////////////////////////////////////////////////////////////////////////////////////
 33 ///////////////////////////////////////////////////////////////////////////////////////////////////
 34 @interface UIEventFake : NSObject {
 35   @public
 36   CFTypeRef               _event;
 37   NSTimeInterval          _timestamp;
 38   NSMutableSet*           _touches;
 39   CFMutableDictionaryRef  _keyedTouches;
 40 }
 41 
 42 @end
 43 
 44 
 45 ///////////////////////////////////////////////////////////////////////////////////////////////////
 46 ///////////////////////////////////////////////////////////////////////////////////////////////////
 47 ///////////////////////////////////////////////////////////////////////////////////////////////////
 48 @implementation UIEventFake
 49 
 50 @end
 51 
 52 
 53 ///////////////////////////////////////////////////////////////////////////////////////////////////
 54 ///////////////////////////////////////////////////////////////////////////////////////////////////
 55 ///////////////////////////////////////////////////////////////////////////////////////////////////
 56 @interface UITouch (TTCategory)
 57 
 58 /**
 59  *
 60  */
 61 - (id)initInView:(UIView *)view location:(CGPoint)location;
 62 
 63 /**
 64  *
 65  */
 66 - (void)changeToPhase:(UITouchPhase)phase;
 67 
 68 @end
 69 
 70 
 71 ///////////////////////////////////////////////////////////////////////////////////////////////////
 72 ///////////////////////////////////////////////////////////////////////////////////////////////////
 73 ///////////////////////////////////////////////////////////////////////////////////////////////////
 74 @implementation UITouch (TTCategory)
 75 
 76 
 77 ///////////////////////////////////////////////////////////////////////////////////////////////////
 78 - (id)initInView:(UIView *)view location:(CGPoint)location {
 79   if (self = [super init]) {
 80     _tapCount = 1;
 81     _locationInWindow = location;
 82     _previousLocationInWindow = location;
 83 
 84     UIView *target = [view.window hitTest:_locationInWindow withEvent:nil];
 85     _view = [target retain];
 86     _window = [view.window retain];
 87     _phase = UITouchPhaseBegan;
 88     _touchFlags._firstTouchForView = 1;
 89     _touchFlags._isTap = 1;
 90     _timestamp = [NSDate timeIntervalSinceReferenceDate];
 91   }
 92   return self;
 93 }
 94 
 95 
 96 ///////////////////////////////////////////////////////////////////////////////////////////////////
 97 - (void)changeToPhase:(UITouchPhase)phase {
 98   _phase = phase;
 99   _timestamp = [NSDate timeIntervalSinceReferenceDate];
100 }
101 
102 
103 @end
104 
105 
106 ///////////////////////////////////////////////////////////////////////////////////////////////////
107 ///////////////////////////////////////////////////////////////////////////////////////////////////
108 ///////////////////////////////////////////////////////////////////////////////////////////////////
109 @implementation UIEvent (TTCategory)
110 
111 
112 ///////////////////////////////////////////////////////////////////////////////////////////////////
113 - (id)initWithTouch:(UITouch *)touch {
114   if (self == [super init]) {
115     UIEventFake *selfFake = (UIEventFake*)self;
116     selfFake->_touches = [[NSMutableSet setWithObject:touch] retain];
117     selfFake->_timestamp = [NSDate timeIntervalSinceReferenceDate];
118 
119     CGPoint location = [touch locationInView:touch.window];
120     GSEventFake* fakeGSEvent = [[GSEventFake alloc] init];
121     fakeGSEvent->x = location.x;
122     fakeGSEvent->y = location.y;
123     selfFake->_event = fakeGSEvent;
124 
125     CFMutableDictionaryRef dict = CFDictionaryCreateMutable(kCFAllocatorDefault, 2,
126       &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
127     CFDictionaryAddValue(dict, touch.view, selfFake->_touches);
128     CFDictionaryAddValue(dict, touch.window, selfFake->_touches);
129     selfFake->_keyedTouches = dict;
130   }
131   return self;
132 }
133 
134 
135 @end
136 
137 #endif

 

 

posted on 2012-11-21 16:23  不及格的程序员-八神  阅读(401)  评论(0编辑  收藏  举报