2011-04-01 38 views
1

我在延長的UIView類接收以下警告,而且不知道爲什麼:+左操作數是垃圾值

enter image description here

而且,沒有人知道這些藍色箭頭是假設代表?

它是使用下面的函數初始化:

- (void)updateIndicators { 
    if (indicator) { 
     [indicator removeFromSuperview]; 
    } 

    if (mode == MBProgressHUDModeDeterminate) { 
     self.indicator = [[[MBRoundProgressView alloc] initWithDefaultSize] autorelease]; 
    } 
    else if (mode == MBProgressHUDModeCustomView && self.customView != nil){ 
     self.indicator = self.customView; 
    } else { 
     self.indicator = [[[UIActivityIndicatorView alloc] 
          initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge] autorelease]; 
     [(UIActivityIndicatorView *)indicator startAnimating]; 
    } 


    [self addSubview:indicator]; 
} 
+0

你是什麼類的擴展韌皮類? – 2011-04-01 00:27:23

+0

@Jordaan:UIView – Casebash 2011-04-01 00:32:01

+0

藍色箭頭表示將導致它突出顯示的錯誤的程序流程。 – 2011-04-01 00:42:25

回答

2

如果indicator還不是視圖層次的一部分,那麼它的bounds屬性將是無用的。

試試這個...

CGRect indicatorFrame = indicator.frame; 
self.width = indicatorFrame.size.width + 2 * margin; 
self.height = indicatorFrame.size.width + 2 * margin; 
+0

好的建議,但是不能解決警告 – Casebash 2011-04-01 00:50:39

+0

什麼類型的對象是'indicator',它是如何被初始化的? – 2011-04-01 00:52:09

+0

'indicator'是一個'UIView'。看起來,' - (id)initWithFrame:(CGRect)frame'或' - (id)initWithView:(UIView *)view'在一系列函數之後啓動它,但另一種調用init的方式並不會在全部 – Casebash 2011-04-01 01:08:34