views:

316

answers:

1

I have a subview over my UITable that is used as a "busy view". It holds an activity indicator and labels. I call it when the program is going to download a photo that is indexed in the cell. All that works fine but the problem is that when I'm scrolling down the UITable and then click on a cell and the "busy view" gets added it will show up at the top of the screen or off the screen because it scrolled up too. How can I keep the second subview from scrolling and stay in place in the center of the screen? I've tried the "center" property and that doesn't help.

Thanks

A: 

Don't add the 'busy view' to the table view, add it to the window. This will place it above everything else onscreen:

[self.view.window addSubview: busyView];
Jim Dovey
Jim, I tried this but then it didn't show the view at all. here is my code: busyView = [[BusyView alloc] initWithNibName:@"BusyView" bundle:[NSBundle mainBundle]]; [self.view addSubview:busyView.view];
Xcoder
It should just be a case of using [self.view.window addSubview: busyView.view]. Also, it sounds as though 'BusyView' is actually an subclass of 'UIViewController' rather than 'UIView' -- in which case it's probably better to name your subclass BusyViewController for better clarity.
Jim Dovey
Make sure that self.view and self.view.window are both non-nil before adding to them. If you're doing this in an init call, for example, it may not work. If you're doing it before you show self.view to the window, it will not work. You could try adding it to the window by instead using [(UIWindow *)([[UIApplication sharedApplication].windows objectAtIndex:0]) addSubview: busyView];
Ed Marty
Thanks to both of you for the suggestions. Ed, yours worked. I ended up using [(UIWindow *)([[UIApplication sharedApplication].windows objectAtIndex:0]) addSubview: busyView.view];
Xcoder