爲什麼myView在init之後是dealloc?初始化後的UIViewController dealloc
MainViewController:
[MOBubbleView hudWithBody:@"123123" bubblePoint:CGPointMake(220, headerMenu.center.y) hidesAfter:2 show:YES];
MOBubbleView.h:
@interface MOBubbleView : UIViewController
@property (nonatomic, assign) float hudHideDelay;
@property (nonatomic, strong) UIColor *itemColor;
+ (MOBubbleView*)hudWithBody:(NSString*)body bubblePoint:(CGPoint)rect hidesAfter:(float)delay show:(BOOL)show;
@end
MOBubbleView.m:
+ (MOBubbleView*)hudWithBody:(NSString*)body bubblePoint:(CGPoint)point hidesAfter:(float)delay show:(BOOL)show {
MOBubbleView *bubble = [[MOBubbleView alloc] init];
///....
if (show) [bubble addToWindow];
return bubble;
}
- (void)addToWindow {
[[[[UIApplication sharedApplication] delegate] window] addSubview:self.view];
}
- (void)loadView {
CGRect bounds = [[UIScreen mainScreen] bounds];
self.view = [[UIView alloc] initWithFrame:bounds];
[self.view setBackgroundColor:[UIColor clearColor]];
/// .. my animation
}
- (void) dealloc {
NSLog(@"Close myView");
}
@end
什麼保留'MOBubbleView'?爲什麼不使用名稱'MOBubbleViewController'(給定一個「視圖」不是「視圖控制器」)? – trojanfoe
「myView alloc」中的myView是什麼?這可能是不正確的。 – proxi
更新了我的帖子 –