分段控件中的 NSArray 问题 [英] NSArray issue in segmentedcontrol
本文介绍了分段控件中的 NSArray 问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用这个示例来创建分段视图.在我的 viewDidLoad
方法中,我收到警告和代码崩溃.
I used this example to create a segmented view. In my viewDidLoad
method I am getting a warning and code crashes.
- (void)viewDidLoad {
[super viewDidLoad];
self.segmentedViewControllers = [self segmentedViewControllerContent];
NSArray * segmentTitles = [self.segmentedViewControllers arrayByPerformingSelector:@selector(title)];
self.segmentedControl = [[UISegmentedControl alloc] initWithItems:segmentTitles];
self.segmentedControl.selectedSegmentIndex = 0;
self.segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar;
[self.segmentedControl addTarget:self
action:@selector(didChangeSegmentControl:)
forControlEvents:UIControlEventValueChanged];
self.navigationItem.titleView = self.segmentedControl;
[self.segmentedControl release];
[self didChangeSegmentControl:self.segmentedControl];
}
我在这一行收到警告:
NSArray * segmentTitles = [self.segmentedViewControllers arrayByPerformingSelector:@selector(title)];
NSArray 可能不会响应 arrayByPerformingSelector.
推荐答案
arrayByPerformingSelector:
不是要发送到 NSArray
的有效消息.这个方法很可能在原代码使用的NSArray
的类别扩展之一中.检查您所遵循的原始示例并尝试找到 arrayByPerformingSelector:
的定义位置,然后在您的代码中找到该文件的 #import
.
arrayByPerformingSelector:
is not a valid message to be sent to NSArray
. This method is probably in one of the category extensions of NSArray
that the original code uses. Check the original example you are following and try to find where arrayByPerformingSelector:
is defined, then #import
that file in your code.
这篇关于分段控件中的 NSArray 问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文