Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ulquiorra

macrumors member
Original poster
Jun 17, 2009
38
0
Does anyone know if it's possible to center my image when using a navigationController.
With this I mean the following. When I click on a cell everything is fine ( figure 1 )

figure 1.
step 1

http://img441.imageshack.us/img441/5026/picture5t.png

step 2

http://img70.imageshack.us/img70/3998/picture6a.png


I go back and want to click another cell , however this time I like to scroll down and click one of my bottom cells( which are out of my view). Well my imageview is being added only outside the view ( almost at the top of the navigationController , which is correct ) so unless I scroll to the top. Is it possible to have some sort of property with which accesses some sort of current image status and have it centered at all time. So not like this, so that I have to scroll up to see it( figure 2 )

figure 2


http://img186.imageshack.us/img186/3012/picture7l.png


I want to keep using
Code:
    [self.view addSubview:videoImageView];
Instead of

Code:
    [self.navigationController.view addSubview:videoImageView];
The latter which pretty much does the trick , unfortunately it does other things as well which are most definately not good;).
I really want to use the first one.

Of course a hackish way is making sure my view skips to the toprow of my UITableView when I select one of the rows that are not in "sight".

Does anyone have a clue or an idea?
 
I would suggest not adding as a subview to the current view, but instead presenting a new view as part of a new view controller, either as part of a navigation controller or as a modal view. That way you keep the logic for dealing with the video view separate from the logic for the table view.
 
thanks again for your reply.
Do you mean pushing a new view onto the stack instead of adding it as subView?
 
mmm ok ... but wouldn't that mean creating a new nibfile for my imageview?
 
I tried your approach

unfortunately to no avail

Code:
[self.navigationController pushViewController:videoImageView animated:YES];


I have to tell you though that my videoImageView is as you can guess an imageview
Code:
videoimage = [UIImage imageNamed:pictures];
    videoImageView = [[UIImageView alloc] initWithImage:videoimage];
	videoImageView.frame = CGRectMake(0, 117 + moveItem, 320, 280);

and the error I'm getting when executing in runtime is this one

reason: '*** -[UIImageView setParentViewController:]: unrecognized selector

Forgive my confusion..
 
Create a UIViewController and use videoImageView as its view. Then push that. As in:
Code:
UIViewController *videoImageViewController = [[UIViewController alloc] init];
videoImageViewController.view = videoImageView;
[self.navigationController pushViewController: videoImageViewController animated:YES];
[videoImageViewController release];
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.