I am having many unsolvable problems in Tiger dealing with controls created programatically rather than in Interface Builder. Many features simply do not work in code that worked fine before. Here is an example:
1. Create one control in IB (in this case a check box)
2. In program, copy that control to another NSBox using
- (void)copyButton:(NSButton *)srcBtn ofType:(NSButtonType)aType toBox:(NSBox *)box { // create new NSButton NSButton *newBtn=[[NSButton alloc] init]; [newBtn setFrame:[srcBtn frame]]; [box addSubview:newBtn];
// copy properties from source button NSButtonCell *btnCell=[newBtn cell]; NSButtonCell *srcCell=[newBtn cell]; [btnCell setButtonType:aType]; [btnCell setControlSize:[srcCell controlSize]]; [btnCell setFont:[srcCell font]]; [btnCell setTitle:[srcCell title]]; [btnCell setBezelStyle:[srcCell bezelStyle]]; [btnCell setImage:[srcCell image]]; [btnCell setImagePosition:[srcCell imagePosition]];
// release and return [newBtn release]; }
3. Finally set delegate and target of the new button
When used for check boxes, both the original and the copied button work, but the new button does not change state when clicked. When clicked it sends a message to the target in which [control state] has the correct value (i.e. toggles between on and off), but the returned state of the control does not match the visual state of the control. The original button created in IB, however, works fine (all in the same code). Furthermore, this identical code worked correctly before Tiger?
Has any one else had problems with programatically created controls in Tiger? --------------- John Nairn (1-801-581-3413, FAX:1-801-581-4816) |