综合开发

UIViewController may not respond to methodName :::

微信扫一扫,分享到朋友圈

UIViewController may not respond to methodName :::

I’m trying to use methods to pass values from text fields in one view to corresponding text fields in another view. The action valuesChanged is wired to the event “Editing Did End” on the text fields. I tried using “Value Changed” with similar results (it doesn’t work.). The only warning I receive is in a method call.

Here’s the code for the VolumeViewController:

@implementation VolumeViewController
@synthesize boxWidth;
@synthesize boxHeight;
@synthesize boxLength;
@synthesize sphereRadius;
@synthesize boxResult;
@synthesize sphereResult;
@synthesize areaViewController;
-(IBAction)valuesChanged:(id)sender
{
NSString *length = boxLength.text;
NSString *width = boxWidth.text;
NSString *radius = sphereRadius.text;
NSLog(@"length: %@", length);
NSLog(@"width: %@", width);
NSLog(@"radius: %@", radius);
[areaViewController changeValues:width :length :radius];
}
-(void)changeValues:(NSString*)widthString :(NSString*)lengthString :(NSString*)radiusString
{
boxWidth.text = widthString;
boxLength.text = lengthString;
sphereRadius.text = radiusString;
}

As you can see, the valuesChanged action instantiates three NSString objects, each corresponding to the text properties of a text field. These strings are then passed to the changeValues method of the areaViewController. The areaViewController’s changeValues method is identical to the volumeViewController’s method, other than the text field names being different. However, the NSLog commands that I have never show anything in the console, so it’s obvious that despite my text fields being connected to the action, it is not being called. What do I need to fix?

The warning is given after the method call “[areaViewController changeValues:width :length :radius], and it reads ‘UIViewController‘ may not respond to ‘-changeValues:::’

谷歌宣布恢复 Chrome 、Chrome OS 更新

上一篇

IDC官方盖戳,百度地图多重举措展现AI战“疫”…

下一篇

你也可能喜欢

评论已经被关闭。

插入图片

热门栏目

UIViewController may not respond to methodName :::

长按储存图像,分享给朋友