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