所選答案適用於我,但它給了我一個語義警告。即使代碼正常工作,我仍然對警告保持警惕,所以我想知道是否有辦法在沒有警告的情況下使其工作。
的警告是:
實例方法「-SetPrompt:」未找到(返回類型默認爲「身份證」)
這裏是在沿在這個問題的答案下面我做了什麼。
在調用.m文件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
vcSelection *ViewSelection = [[vcSelection alloc] initWithNibName:@"vcSelection" bundle:nil];
ViewSelection.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
if ([[SettingsTableData objectAtIndex:indexPath.row] isEqualToString:DeviceType])
{
[ViewSelection SetPrompt:@"Select the device type."];
}
else if ([[SettingsTableData objectAtIndex:indexPath.row] isEqualToString:DeviceManufacturer])
{
[ViewSelection SetPrompt:@"Select the device manufacturer."];
}
else if ([[SettingsTableData objectAtIndex:indexPath.row] isEqualToString:DeviceModel])
{
[ViewSelection SetPrompt:@"Select the device model."];
}
[self.view addSubview:ViewSelection.view];
}
在接收.m文件
@implementation vcSelection
NSMutableString *Prompt;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Debug"
message:Prompt
delegate:self
cancelButtonTitle:@"Done"
otherButtonTitles:nil];
[alert show];
[alert release];
}
- (void) SetPrompt:(NSMutableString *)Value
{
Prompt = Value;
}
@end
謝謝哥們..:P :) – shivam 2013-05-16 08:37:20