Sorting Segues Sanely

There are three kinds of segues, push, modal and custom. You’ll probably most often use the ‘push’ method. It is incredibly useful in making storyboards do stuff.

Primarily there are two ways to invoke a segue. One is to rig up a button in Interface Builder that triggers a segue. The other is to invoke the segue on your own. I think that a lot of times I need to validate what’s on the screen before I can release it to the next controller. Therefore I need to do it myself.

Also you need to pass information back and forth, which will be taken care of by setting variables in the method:

-(void) prepareForSegue:(UIStoryBoardSegue *)segue sender:(id)sender {
//...
}

Continue reading

Programmatically Setting a UISegmentedControl From IB

I added my UISegmentedControl from Interface Builder easily enough. I just wanted needed to change it to the needs of the data.

BUT…since I added it in interface builder I cannot use initWithArray: so I need to connect it up in Xcode, clear it out and then add in what I need. Then we’ll update the app when the UISegmentedControl is updated.

@interface TopicViewController : UIViewController
 
@property (strong, nonatomic) IBOutlet UIButton *filterButton;
@property (strong, nonatomic) IBOutlet UISegmentedControl *filterSegmented;
 
-(void)segmentChanged:(id)sender;

Continue reading