0
我有一個UIViewController
Class Aplha
調用另一個UIViewController
Class Beta
在modalView。
在Alpha.h
,我聲明的函數:使用委託調用調用的函數的ViewController給出錯誤的iOS 5
-(void)selectMyImage:(NSString *)myImage;
在Aplha.m:
#import "Beta.h"
-(IBAction)clickMe:(id)sender
{
Beta *b=[[Beta alloc]initWithNibName:@"Beta" bundle:nil];
b.delegate=self;
[self presentModalViewController:b animated:YES];
}
上面的代碼表示的viewController中模態的視圖。我在Beta.h
中聲明瞭id delegate;
。現在,當我嘗試從Beta
類調用Alpha
的功能時,它給我錯誤。
這裏是Beta.m
我的代碼:
-(void)callAlpha
{
[delegate selectMyImage:imagename]; //imagename is declared in Beta.h too.
}
Xcode的顯示紅色的錯誤標記說"No known instance method for selector 'mySelectedImage:'"
在iOS版SDK 4.x中運行良好。在這裏我也有啓用了ARC。
你是指「聲明alpha和beta都能看到的地方」的含義? – 2011-12-17 08:32:32