开发者

Why is my segmented control not showing in my view?

开发者 https://www.devze.com 2023-03-15 16:26 出处:网络
My segmented control in the xib view doesn\'t show up when I run the application. Please help me! m File

My segmented control in the xib view doesn't show up when I run the application. Please help me!

m File

- (IBAction) segmentedControlIndexChanged{
  switch (self.segmentedControl.selectedSegmentIndex) {
    case 0:
          self.carImage.image = [UIImage imageNamed:@开发者_Go百科"someimage.png"];
      break;
    case 1:
          self.carInfo.text = @"Segmented 1 selected.";
      break;
      case 3:
          self.carImage.image = [UIImage imageNamed:@"middleRow.png"];
          break;
    default:
       break;
   } 
}
@end

h File

IBOutlet UIImageView *carImage;
UISegmentedControl *segmentedControl;
IBOutlet UILabel *carInfo;
}

@property (nonatomic, retain) UIImageView *carImage;
@property (nonatomic, retain) UILabel *carInfo;
@property (nonatomic, retain) IBOutlet UISegmentedControl *segmentedControl;

- (IBAction) segmentedControlIndexChanged;

@end


Your segmented control should be showing up regardless of whether you actually have it connected correctly or not. Can you see it in your .xib from when you dragged it out? If you have other UI is it possibly hiding underneath another view. If you show the detail view of your document window you can see the view hierarchy. Aside from this post a screenshot of your .xib if you're still having trouble.


I don't know what version of Xcode you are using, but I often had a similar problem with Xcode 3.2 and the separate Interface Builder. It happened when I hadn't properly saved the .nib file in IB. In Xcode 4, that doesn't happen to me anymore.

0

精彩评论

暂无评论...
验证码 换一张
取 消