【问题标题】:How to fix "signal SIGABRT" when using self.UISegmentedControl.selectedSegmentIndex使用 self.UISegmentedControl.selectedSegmentIndex 时如何修复“信号 SIGABRT”
【发布时间】:2019-05-27 16:10:20
【问题描述】:

每次我使用"self.SegControl.selectedSegmentIndex" 时,我都会在以下code 中获得SIGABRT 信号:

int main(int argc, char * argv[]) {
    @autoreleasepool {
        return UIApplicationMain(argc, argv, nil,     NSStringFromClass([AppDelegate class]));// signal SIGABRT
    }
}

我试图找到self.SegControl.selectedSegmentIndex 的值:

long a=self.SegControl.selectedSegmentIndex;

但是,我发现我什至不能使用self.SegControl.selectedSegmentIndex

...
@property (weak, nonatomic) IBOutlet UISegmentedControl *SegControl;
...
- (IBAction)Button:(id)sender {
NSMutableString *str=[NSMutableString new];
if(self.SegControl.selectedSegmentIndex==0){
    [str appendString:@"unit 2"];
}
else if(self.SegControl.selectedSegmentIndex==1){
    [str appendString:@"unit 3"];
}
else if(self.SegControl.selectedSegmentIndex==2){
    [str appendString:@"unit 4"];
}
self.Output.text=str;
}
...

我想得到 self.SegControl.selectedSegmentIndex 的输出。我想让我的程序知道选择了哪个段。 请帮帮我! 谢谢!

【问题讨论】:

    标签: objective-c uisegmentedcontrol sigabrt


    【解决方案1】:

    在 if 语句的时刻是否选择了任何索引?

    在您的故事板中,您是否有任何选定的索引作为默认值?有一个复选框,您可以在其中设置默认选定索引的行为。或者您应该在 if 语句之前以编程方式执行此操作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-02-14
      • 1970-01-01
      • 1970-01-01
      • 2015-12-04
      • 2018-10-25
      • 2021-06-17
      相关资源
      最近更新 更多