Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/algorithm/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 尝试创建处理多个对象类型参数的方法时发生生成错误_Ios_Objective C - Fatal编程技术网

Ios 尝试创建处理多个对象类型参数的方法时发生生成错误

Ios 尝试创建处理多个对象类型参数的方法时发生生成错误,ios,objective-c,Ios,Objective C,我有一个实例方法,试图将最后一条语句概括为处理多个对象类: -(void)showHTMLHelp:(NSString *)htmlString pointTo:(id)target background:(UIColor *)bgColor 在这里,直到运行时我才知道目标对象是什么类。这是执行检查的代码(第2条语句导致生成错误): 这是生成错误: 在类型为“\u strong id”的对象上找不到属性“frame” 为什么??我对正确的类进行了转换,所有目标都有实际的“帧”(UITabl

我有一个实例方法,试图将最后一条语句概括为处理多个对象类:

-(void)showHTMLHelp:(NSString *)htmlString pointTo:(id)target background:(UIColor *)bgColor  
在这里,直到运行时我才知道目标对象是什么类。这是执行检查的代码(第2条语句导致生成错误):

这是生成错误:

在类型为“\u strong id”的对象上找不到属性“frame”


为什么??我对正确的类进行了转换,所有目标都有实际的“帧”(UITableView、UITextField和UITextView)。

如果你的目标没有实际的帧(原点x、原点y、宽度、高度),你不能呈现PopoverFromRect,因为它不知道从哪里弹出。 试一试

CGRectMake是您的(原点x、原点y、宽度、高度)

这不起作用,因为“目标”是popover箭头指向的位置。。。所有目标都有实际的“帧”(UITableView、UITYextyField和UITextView)。
    if([target isKindOfClass: [UITextField class]])
    [popoverController presentPopoverFromRect:(UITextField)&target.frame inView:self.view
                     permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
if([target isKindOfClass: [UITextField class]])
[popoverController presentPopoverFromRect::CGRectMake(0, 0, 100, 100) inView:self.view
                 permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
if([target isKindOfClass: [UITextField class]])
    [popoverController presentPopoverFromRect:((UITextField *)target).frame inView:self.view
                     permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];