2012-10-12 86 views
0

我想從視圖控制器類調用下面的(滾動動畫類)類型的方法。傳遞參數到UILabel [2] *

-(void)CreateLabel:(CGRect)frame andLabel:(UILabel *[NUM_LABELS])label andview:(UIView *)view; 

當我嘗試傳遞參數時,出現了一些錯誤。有關如何調用這個的任何建議?

這是我怎麼叫那個方法

ScrollAnimation *newAnimation = [[ScrollAnimation alloc] init]; 
[newAnimation CreateLabel:CGRectMake(0, 50, 300,30) andLabel:animateLabel[NUM_LABELS] andview:self.view]; 

我有錯誤

/Volumes/Red Drive/CarTransition/CarTransition/ViewController.m:120:66: Implicit conversion of an Objective-C pointer to 'UILabel **' is disallowed with ARC 


/Volumes/Red Drive/CarTransition/CarTransition/ViewController.m:120:66: Incompatible pointer types sending 'UILabel *__strong' to parameter of type 'UILabel **' 

創建標籤的方法:

-(void)CreateLabel:(CGRect)frame andLabel:(UILabel *[NUM_LABELS])label andview:(UIView *)view{ 
for (int i = 0; i<NUM_LABELS ; i++){ 

    if(i == 0){ 
     label[0] = [[UILabel alloc] initWithFrame:CGRectMake(frame.origin.x, frame.origin.y, frame.size.width,frame.size.height)]; 
     label[i].text = @"MINI "; 
    }else if(i == 1){ 
     label[1] = [[UILabel alloc] initWithFrame:CGRectMake(frame.origin.x, frame.origin.y - 40 ,frame.size.width, frame.size.height)]; 
     label[1].text = @"COOPER "; 
    }else if(i == 2){ 
     label[2] = [[UILabel alloc] initWithFrame:CGRectMake(frame.origin.x, frame.origin.x-120 ,frame.size.width,frame.size.height)]; 
     label[2].text = @"STYLING"; 
    } 
} 
+0

請提供代碼,其中定義了'animateLabel'。 – Resh32

+0

增加了方法 – DesperateLearner

回答

0

你的方法是問指針數組。

這裏有一個髒例如:

- (void)passArgument:(NSObject *[])anObject total:(uint)total{ 
    for (int i = 0; i < total; i++) { 
     NSLog(@"list --> %@", anObject[i]); 
    } 
} 

現在呼叫:

NSString* object[5] = {@"a", @"b", @"c", @"d", @"e"}; 
[self passArgument: object total: 5]; 
[self passArgument: &object[2] total: 3]; 
  1. 注意:目的是指針的數組,(*)
  2. &對象[2]是指針的地址(& **)
  3. object [1]是指向一個指針(**),這不是你想要的