I have a main view. It calls up a subView (UIView) like so: In the .m of the view controller:
#import "SettingsView.h" //this is my UIView class ... NSArray *nibViews = [[NSBundle mainBundle] loadNibNamed:@"Settings" owner: self options:nil]; SettingsView *settingsView = (SettingsView *)[nibViews objectAtIndex:0]; [self.view addSubview:settingsView]; This seems to work. initWithCoder gets called, then drawRect. The xib really only contains a UIImageView with a background image in it. In the SettingsView class I have code that sets up it's UI: .h: #import <UIKit/UIKit.h> @interface SettingsView : UIView { } @end .m: #import "SettingsView.h" #import "AnalogAppDelegate.h" - (void) pickOne:(id)sender { //This doesn't seem to want to work AnalogAppDelegate *appDelegate = (AnalogAppDelegate *)[[UIApplication sharedApplication] delegate]; switch ( [((UISegmentedControl *)sender) selectedSegmentIndex]) { case 0: [appDelegate stopSleep:YES]; //crashes app break; case 1: [appDelegate stopSleep:NO]; //crashes app break; } } - (void)layoutSubviews { UIButton * btn = [UIButton buttonWithType:UIButtonTypeRoundedRect]; btn.frame = CGRectMake(120, 300, 80, 30); [btn setTitle:@"OK" forState:UIControlStateNormal]; [btn addTarget:self action:@selector(aMethod:) forControlEvents:UIControlEventTouchDown]; [self addSubview:btn]; NSArray *itemArray = [NSArray arrayWithObjects: @"Enabled", @"Disabled", nil]; UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:itemArray]; segmentedControl.frame = CGRectMake(40, 44, 240, 29); segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar; segmentedControl.selectedSegmentIndex = 1; [segmentedControl addTarget:self action:@selector(pickOne:) forControlEvents:UIControlEventValueChanged]; [self addSubview:segmentedControl]; } - (void) aMethod:(id)sender { [self removeFromSuperview]; } In the AnalogAppDelegate I have this simple method: .h: - (void) stopSleep:(BOOL)shouldStop; .m: - (void) stopSleep:(BOOL)shouldStop { NSLog(@"stop sleep %@", shouldStop); } I am wondering why the app crashes when I try this. I don't see anything in the debug console, it just dies. -- http://ericd.net Interactive design and development _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com