UITableView position - iphone

my app uses a tab bar with 2 navigation based views in which I am adding a custom view (a title bar) between the nav bar and the table view .
- (void)viewDidLoad {
[super viewDidLoad];
// load title bar controller
TitleBarViewController *tbar = [[TitleBarViewController alloc] init];
[tbar setTitleImage:[UIImage imageNamed:#"v2-une.png"]];
[self setTitleBar:tbar];
[tbar release];
// show title bar
[self.navigationController.view addSubview:self.titleBar.view];
....
When the application is launched with a default selected nav view, I use (void)viewDidAppearBOOL)animated to set the table view to a lower Y value so that the title bar is visible.
Where Y = 20 : 20 is the height of my title bar.
self.tableView.frame = CGRectMake(0, 20, 320, 347);
The problem is that when I select a row and push a detail view and hide the bottom bar to display a toolbar, things are messed up.
my title bar's height increases and becomes > 20 which I can't explain why.
Now when I go back to the main table view, its Y is decreased by 20 and sticked to the nav bar. My title ben then appears above the first cell of the table view.
If hit the 2 tab and then go back to the 1st tab, everything is re arranged like expected.
here are some pics to illustrate all that :
link text
can anyone help me figure out why is this happening please ?
may be I am putting my positioning code in the wrong event ?

Is is possible that the background to everything is black and the tableview is moving down exposing the background, as opposed to the black titleBar actually increasing in size? This makes some sense given that the problem goes away when the tableView moves back up.

Related

Enable ScrollView When Keyboard Appears

I have a UIView with a UINavigation controller and several other Imageviews and a text filed inside it. On the Nagivation bar there is a UIBarbutton item which pushes another ViewController.
When the text field in the Navigation Viewcontroller is tapped it brings up the keyboard causing the Navigation bar with UIBarbutton item to slide out of the screen and thus making the UIBarbutton item unaccessible until the done button is pressed on the keyboard.
A notification is sent to this method whenever the keyboard is invoked.
- (void)displayKeyboard {
self.view.transform = CGAffineTransformTranslate(self.view.transform, 0.0, -100.0);
}
I tried using the IB to add a scrollview onto the view but this causes the entire view to be blocked.
Is there any other way i can enable the scroll view whenever the keyboard appears so i can scoll the entire screen ?
maybe you could try setting the frame of the current view.. for example:
CGRect r = self.view.frame;
self.view.frame = CGRectMake(r.origin.x, r.origin.y, r.size.width, r.size.height-100);
and when the user done with the keyboard, add 100 to bring it back.... (instead of 100, you should get the value from the notification object that contains the height, position of the keyboard)...

setting Y-Axis value of subview in iPhone

[selectorView setFrame:CGRectOffset([selectorView frame], 0, -selectorView.frame.size.height)]
In the above code I want to change the value of Y-axis for my subview, as it gets visible from the top of screen and hides my header and search bar. I want to set it just beneath to search bar.
How can I do that ?
Before visibility
After when subview gets visible
Try this:
[selectorView setFrame:CGRectMake(<CGFloat x> , <CGFloat y>, <CGFloat width>, <CGFloat height>)];
Hope it works for You

Tab Bar controller is not accessible

I have created a tab based application for iphone. when the 1st tab presses a first view will present. this view contains a button, on pressing it another view loads.
Code is:
-(IBAction)buttonPressed: (id) sender
{
Cities *cv=[[Cities alloc] initWithNibName:#"Cities" bundle:nil];
cv.modalTransitionStyle=UIModalTransitionStyleCoverVertical;
[self presentModalViewController:cv animated:YES];
[cv release];
}
Now problem is that this view is loading in whole screen so that I am not able to access tab bar.
I have set the frame for this view and the view is loading in this frame,
-(void)viewWillAppear:(BOOL)animated
{
self.view.frame = CGRectMake(0, 0, self.view.frame.size.width, 400);
}
but in remaining part white screen is appearing means tab bar is not accessible.
I want that whatever will be load at any time tab bar should be always accessible.
Please help me out.
Add
cv.modalPresentationStyle = UIModalPresentationCurrentContext;
Have you tried using UINavigationController inside your tabbar to dig inside your UIViewControllers??
for Ref : Adding NavigationController to Tabbar
do you really need a viewController Class for what you are trying to display??
if der's no core functionality being used, i think it will be much easier with UIView.
Happy Coding :)

UIView bottom not showing

I'm doing a navigation based app. My rootview is a UITableView and from that I'm navigation to a UIView. For some reason the height of the UIView seems bigger than it should, meaning that the bottom of the view is not showing.
I did a really simple test using a UITextView with a button at the bottom, and only the top half of the button shows in the view when i run it in Simulator even though the height is set to 460.
Here's the code I use to navigate:
TestViewController *t = [[TestViewController alloc] initWithNibName:nil bundle:nil];
[self.navigationController pushViewController:t animated:YES];
In my test the .xib is just made in IB dragging a textview and a button to the UIView.
I don't have the same issue when I'm navigating to another UITableView.
What am I missing?
Make sure you have those in the IB
view.autoresizingMask = UIViewAutoresizingFlexibleHeight;
textView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleBottomMargin;
button.autoresizingMask = UIViewAutoresizingFlexibleTopMargin;
which means that the viewControllers' view gets resized by the navigationController, the textView gets resized by the main view and the distance from the top stays the same as in your nib, and finally the distance from the bottom of the view stays the same for your button.
If you don't know how to translate these values in your IB UI, arrows is resizing and "I" is fixed distance to that side - left, top, right, bottom.
The height of the view in a navigation based app should be 480 - statusbarHeight (=20) - navigationBarHeight (=44) = 416 pixels

How to have a scrollview take the space between the uinavigationbar and the uitoolbar

I have a scrollview that I had to the view of the view controller pushed to a UINavigationController.
My navigation bar is opaque.
However, the scrollview seems to keep size of the whole parent view. I would like the scrollview to have the size of the space between the toolbar and the navigationbar.
Is this possible or do I have to hardcode some size values?
Thanks in advance
When you initialize your scrollView you can set its contentSize parameter:
[scrollView setContentSize:CGSizeMake(320,392)];
The height of the screen (480) minus the toolbar (44) and navigation bar (44) = 392. Drop that to 372 if you're also displaying the carrier status bar.
or, use the frame geometry properties:
[scrollView setContentSize:CGSizeMake((scrollView.superview.frame.size.width),
(scrollView.superview.frame.size.height -
toolbar.frame.size.height -
navigationController.navigationBar.frame.height))];
When you use autosize, the correct frame size is not known on viewDidLoad.
You should pack this inside viewWillAppear and then everything works fine
scrollView.contentSize = CGSizeMake(scrollView.superview.frame.size.width, scrollView.superview.frame.size.height);