0

I am experiencing a weird behaviour of my app when loading views from a xib/nib. I cant access my controls I hooked up with interface builder from code any more-- means I cant replace them or change text and sorts. (the controls will still fire IBActions though.. like button-clicks) I had this problem already with a uisearchbar. but extensively deleting and adding it again and reconnceting it in Interface Builder somehow solved the issue. iPad/iPhone uiSearchbar transparent background

I want to avoid doing this with every bloody control in this xib so I tried to nail it down. I found out that as soon as I load a view from my xib, the weird behaviour starts. (though the controls which are already working, as the uisearchbar, keep working)

what I do, is to load a couple of Views(from the same xib the viewcontroller is the owner) to place them into a scrollview. this works nicely..

here is the code:

UIView *viewContainer = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 2304, 575)];
NSArray *nibViews1 = [[NSBundle mainBundle] loadNibNamed:@"ViewController_iPad" owner:self options:nil];
PrescriptionView *view1 = [nibViews1 objectAtIndex:1];
NSArray *nibViews2 = [[NSBundle mainBundle] loadNibNamed:@"ViewController_iPad" owner:self options:nil];
PrescriptionView *view2 = [nibViews2 objectAtIndex:1];
NSArray *nibViews3 = [[NSBundle mainBundle] loadNibNamed:@"ViewController_iPad" owner:self options:nil];
PrescriptionView *view3 = [nibViews3 objectAtIndex:1];
NSMutableArray *arrayViews = [[NSMutableArray alloc] init];
[arrayViews addObject:view1];
[arrayViews addObject:view2];
[arrayViews addObject:view3];
int intX = 1;
int intY = 1; 
for (UIView *viewImage in arrayViews)
{
    [viewImage setFrame:CGRectMake(intX, intY, 768, 575)];
    [viewContainer addSubview:viewImage];
    intX = intX + 768;
}

[arrayViews release];
[prescriptionScrollView setContentSize:CGSizeMake(2304, 575)];
[prescriptionScrollView addSubview:viewContainer];
[viewContainer release];

andy ideas? suggestions? is this a bug?

Thank you very much.

Best regards T

Community
  • 1
  • 1
Tom
  • 65
  • 3
  • 8

2 Answers2

0

As an update for this, I am pretty sure this is a bug. Placing the view into its own nibfile instead of loading the view from within the same xib helped getting rid of this weird behaviour. Anyway, I raised a support ticket with apple, but after rejecting my ticket twice for some dumb reasons, I got tired of trying. thanks to anyone who took the time reading this. cheers!

Tom
  • 65
  • 3
  • 8
0

How are you defining your outlets? They should be defined like this:

@property (nonatomic, retain) IBOutlet MyView *myViewOutlet;

Also note the outlets should be released and nilled in viewDidUnload and dealloc.

Andrew Ebling
  • 10,175
  • 10
  • 58
  • 75