开发者

Outlets and buttons ignored

开发者 https://www.devze.com 2023-02-07 06:48 出处:网络
My problem is that I cannot access any of the controls in a view defined using interface builder. This is the .h code for the Navigation bar (as an example):

My problem is that I cannot access any of the controls in a view defined using interface builder. This is the .h code for the Navigation bar (as an example):

#import <UIKit/UIKit.h>

@interface myController : UIViewController {
    IBOutlet UINavigationBar *tTitle;
}
@property (nonatomic,retain) UINavigationBar *tTitle;
@end

The implementation (.m) is:

#import "myController.h"

@implementation myController
@synthesize tTitle;

- (void)dealloc {
    [tTitle release];
    [super dealloc];
}
- (void)viewDidLoad {
    tTitle.topItem.title=@"This is my title";
}

In viewDidLoad tTitle (and my other outl开发者_C百科ets) are always 0x0. I have omitted the two text fields and the button for brevity.

This exact code works in another view in the app without issue. In IB I right click on the file owner icon and it shows my outlets correctly (and the single button action). Yet at run time - nada. I click the button and no response. The title is still the default title. I cannot set the text fields text property because the fields are all 0x0.

The view is linked to the view controller. As near as I can tell everything is identical between the two views that are doing the same thing. Obviously something is awry, but I can't figure it out. Any help would be appreciated.


Okay. I did the ROI and figured it would be easier to delete and recreate the view (one control at a time) in an attempt to see where it was going awry. The answer is the title bar title set worked from the get-go. I have no idea why the other class didn't work. But discretion is the better part of valor in this situation. The new class is working fine. Thanks for everyone's input.

0

精彩评论

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