Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.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
Iphone UIView addSubview:方法错误问题_Iphone_Objective C_Uiview - Fatal编程技术网

Iphone UIView addSubview:方法错误问题

Iphone UIView addSubview:方法错误问题,iphone,objective-c,uiview,Iphone,Objective C,Uiview,我有代码来添加一个视图[self.view addSubview:RootViewController.view]它给了我一个错误错误:访问未知的“view”类方法 这里有更多可能有用的东西 CompileC build/iTracker.build/Debug-iphoneos/iTracker.build/Objects-normal/armv6/NewLogViewController.o Classes/NewLogViewController.m normal armv6 object

我有代码来添加一个视图
[self.view addSubview:RootViewController.view]
它给了我一个错误
错误:访问未知的“view”类方法

这里有更多可能有用的东西

CompileC build/iTracker.build/Debug-iphoneos/iTracker.build/Objects-normal/armv6/NewLogViewController.o Classes/NewLogViewController.m normal armv6 objective-c com.apple.compilers.gcc.4_2
cd /Users/markszymanski/Desktop/Programming/iTracker
setenv LANG en_US.US-ASCII
setenv PATH "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 -x objective-c -arch armv6 -fmessage-length=0 -pipe -std=c99 -Wno-trigraphs -fpascal-strings -O0 -Wreturn-type -Wunused-variable -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.3.sdk -fvisibility=hidden -gdwarf-2 -mthumb -miphoneos-version-min=3.1.3 -iquote /Users/markszymanski/Desktop/Programming/iTracker/build/iTracker.build/Debug-iphoneos/iTracker.build/iTracker-generated-files.hmap -I/Users/markszymanski/Desktop/Programming/iTracker/build/iTracker.build/Debug-iphoneos/iTracker.build/iTracker-own-target-headers.hmap -I/Users/markszymanski/Desktop/Programming/iTracker/build/iTracker.build/Debug-iphoneos/iTracker.build/iTracker-all-target-headers.hmap -iquote /Users/markszymanski/Desktop/Programming/iTracker/build/iTracker.build/Debug-iphoneos/iTracker.build/iTracker-project-headers.hmap -F/Users/markszymanski/Desktop/Programming/iTracker/build/Debug-iphoneos -I/Users/markszymanski/Desktop/Programming/iTracker/build/Debug-iphoneos/include -I/Users/markszymanski/Desktop/Programming/iTracker/build/iTracker.build/Debug-iphoneos/iTracker.build/DerivedSources/armv6 -I/Users/markszymanski/Desktop/Programming/iTracker/build/iTracker.build/Debug-iphoneos/iTracker.build/DerivedSources -include /var/folders/lv/lv+C4SRgFKyKVw+w5z1F-++++TM/-Caches-/com.apple.Xcode.502/SharedPrecompiledHeaders/iTracker_Prefix-faiusrzfiirznderkbprgchdlcni/iTracker_Prefix.pch -c /Users/markszymanski/Desktop/Programming/iTracker/Classes/NewLogViewController.m -o /Users/markszymanski/Desktop/Programming/iTracker/build/iTracker.build/Debug-iphoneos/iTracker.build/Objects-normal/armv6/NewLogViewController.o

/Users/markszymanski/Desktop/Programming/iTracker/Classes/NewLogViewController.m: In function '-[NewLogViewController addLog]':
/Users/markszymanski/Desktop/Programming/iTracker/Classes/NewLogViewController.m:22: warning: passing argument 1 of 'addSubview:' makes pointer from integer without a cast
/Users/markszymanski/Desktop/Programming/iTracker/Classes/NewLogViewController.m:22: error: accessing unknown 'view' class method
{standard input}:515:non-relocatable subtraction expression, "L_OBJC_SELECTOR_REFERENCES_11" minus "L50"
{standard input}:515:symbol: "L_OBJC_SELECTOR_REFERENCES_11" can't be undefined in a subtraction expression
{standard input}:514:non-relocatable subtraction expression, "L_OBJC_CLASSLIST_SUP_REFS_$_0" minus "L49"
{standard input}:514:symbol: "L_OBJC_CLASSLIST_SUP_REFS_$_0" can't be undefined in a subtraction expression
{standard input}:469:non-relocatable subtraction expression, "L_OBJC_SELECTOR_REFERENCES_9" minus "L44"
{standard input}:469:symbol: "L_OBJC_SELECTOR_REFERENCES_9" can't be undefined in a subtraction expression
{standard input}:468:non-relocatable subtraction expression, "L_OBJC_CLASSLIST_REFERENCES_$_2" minus "L43"
{standard input}:468:symbol: "L_OBJC_CLASSLIST_REFERENCES_$_2" can't be undefined in a subtraction expression
{standard input}:467:non-relocatable subtraction expression, "L_OBJC_SELECTOR_REFERENCES_10" minus "L42"
{standard input}:467:symbol: "L_OBJC_SELECTOR_REFERENCES_10" can't be undefined in a subtraction expression
{standard input}:351:non-relocatable subtraction expression, "L_OBJC_SELECTOR_REFERENCES_8" minus "L31"
{standard input}:351:symbol: "L_OBJC_SELECTOR_REFERENCES_8" can't be undefined in a subtraction expression
{standard input}:349:non-relocatable subtraction expression, "L_OBJC_SELECTOR_REFERENCES_7" minus "L29"
{standard input}:349:symbol: "L_OBJC_SELECTOR_REFERENCES_7" can't be undefined in a subtraction expression
{standard input}:348:non-relocatable subtraction expression, "L_OBJC_SELECTOR_REFERENCES_6" minus "L28"
{standard input}:348:symbol: "L_OBJC_SELECTOR_REFERENCES_6" can't be undefined in a subtraction expression
{standard input}:347:non-relocatable subtraction expression, "L_OBJC_CLASSLIST_REFERENCES_$_1" minus "L27"
{standard input}:347:symbol: "L_OBJC_CLASSLIST_REFERENCES_$_1" can't be undefined in a subtraction expression
{standard input}:345:non-relocatable subtraction expression, "L_OBJC_SELECTOR_REFERENCES_5" minus "L23"
{standard input}:345:symbol: "L_OBJC_SELECTOR_REFERENCES_5" can't be undefined in a subtraction expression
{standard input}:159:non-relocatable subtraction expression, "L_OBJC_SELECTOR_REFERENCES_4" minus "L12"
{standard input}:159:symbol: "L_OBJC_SELECTOR_REFERENCES_4" can't be undefined in a subtraction expression
{standard input}:158:non-relocatable subtraction expression, "L_OBJC_CLASSLIST_SUP_REFS_$_0" minus "L11"
{standard input}:158:symbol: "L_OBJC_CLASSLIST_SUP_REFS_$_0" can't be undefined in a subtraction expression
{standard input}:113:non-relocatable subtraction expression, "L_OBJC_SELECTOR_REFERENCES_1" minus "L6"
{standard input}:113:symbol: "L_OBJC_SELECTOR_REFERENCES_1" can't be undefined in a subtraction expression
{standard input}:112:non-relocatable subtraction expression, "L_OBJC_SELECTOR_REFERENCES_3" minus "L5"
{standard input}:112:symbol: "L_OBJC_SELECTOR_REFERENCES_3" can't be undefined in a subtraction expression
{standard input}:111:non-relocatable subtraction expression, "L_OBJC_SELECTOR_REFERENCES_2" minus "L4"
{standard input}:111:symbol: "L_OBJC_SELECTOR_REFERENCES_2" can't be undefined in a subtraction expression
{standard input}:110:non-relocatable subtraction expression, "L_OBJC_SELECTOR_REFERENCES_0" minus "L3"
{standard input}:110:symbol: "L_OBJC_SELECTOR_REFERENCES_0" can't be undefined in a subtraction expression
{standard input}:109:non-relocatable subtraction expression, "L_OBJC_CLASSLIST_SUP_REFS_$_0" minus "L2"
{standard input}:109:symbol: "L_OBJC_CLASSLIST_SUP_REFS_$_0" can't be undefined in a subtraction expression
{standard input}:unknown:Undefined local symbol L_objc_msgSendSuper2$stub
{standard input}:unknown:Undefined local symbol L_objc_msgSend$stub
{standard input}:unknown:Undefined local symbol L_OBJC_CLASSLIST_SUP_REFS_$_0
{standard input}:unknown:Undefined local symbol L_OBJC_SELECTOR_REFERENCES_0
{standard input}:unknown:Undefined local symbol L_OBJC_SELECTOR_REFERENCES_2
{standard input}:unknown:Undefined local symbol L_OBJC_SELECTOR_REFERENCES_3
{standard input}:unknown:Undefined local symbol L_OBJC_SELECTOR_REFERENCES_1
{standard input}:unknown:Undefined local symbol L_OBJC_SELECTOR_REFERENCES_4
{standard input}:unknown:Undefined local symbol L_OBJC_SELECTOR_REFERENCES_5
{standard input}:unknown:Undefined local symbol L_OBJC_CLASSLIST_REFERENCES_$_1
{standard input}:unknown:Undefined local symbol L_OBJC_SELECTOR_REFERENCES_6
{standard input}:unknown:Undefined local symbol L_OBJC_SELECTOR_REFERENCES_7
{standard input}:unknown:Undefined local symbol L_OBJC_SELECTOR_REFERENCES_8
{standard input}:unknown:Undefined local symbol L_OBJC_SELECTOR_REFERENCES_10
{standard input}:unknown:Undefined local symbol L_OBJC_CLASSLIST_REFERENCES_$_2
{standard input}:unknown:Undefined local symbol L_OBJC_SELECTOR_REFERENCES_9
{standard input}:unknown:Undefined local symbol L_OBJC_SELECTOR_REFERENCES_11

提前谢谢

RootViewController
是类的名称,而不是实例的名称。将其更改为类
RootViewController
的对象分配给的变量的名称。

目标C可以在对象中或对象的类类型中具有方法。“视图”方法(本例中为属性)是对象上的方法,而不是类上的方法。该类上没有view方法。JoostK正确地指出,您需要使用对象名(变量),而不是类名

在文档和代码中,以“-”开头的方法是对象方法。以“+”开头的是类方法


类方法通常是工厂方法。大多数情况下,您需要在对象上使用方法,即使用变量。

我遇到了这个错误。我的情况是因为拼写错误。请尝试以下操作:

而不是: [self.view addSubview:RootViewController.view]

替换:注:小资本“r” [self.view addSubview:*r*ootViewController.view

如果不起作用,请关闭您的.h文件以复制并粘贴您的类声明

希望有帮助:)

请支持我的新应用程序-spider smack: 大宗报价