I've created a simple application with a single view controller and removed the status bar so I can use the full height of the screen. The view controller's xib file loads perfectly well, displaying a backdrop image very nicely. I then added a custom view object which will be handling certain graphical tasks directly for me, and asked it to initialize itself with the custom view's frame rectangle. I did this in the 'viewDidLoad' method for the view controller. For some strange reason though, the view controller is reporting its frame rectangle as if the status bar were still visible, despite the fact that I hide it before creating the view controller. Can someone explain why, and maybe suggest a workaround?
-Ash
Oops, it's always the simple things isn't it? I just forgot this command:
viewHolder.wantsFullScreenLayout = YES;
Related
I am currently developing as app for iPad. And I need to create a tabbar. The problem is that, for design purposes, I need the tabbar to be on the top half of the screen and not on the bottom as it is on the default tabbar controller.
Once the tabbar is on top I want that when a button is touched, the subview bellow the tab is changed. Furthermore, the subview that should be loaded was alson designed inside the storyboard. The following sketch shows what I want it to look like:
On my research I found a solution (here) for putting the tabbar on top. Now my problem is on loading a subview bellow it.
I tried it with [self.view addsubview:theNameOfTheViewCreatedINStoryboad.view] but the application simply hangs when I press the button.
I think that is because I am not specifying anywhere what should be the dimension of the new view or where on the scree should it be placed. The reason for that is because I do not know where it should be done.
Can anyone give me some lights on this matter? Is the referred approach the best one for putting a tabbar on top? How can I solve the subview problem?
Glad to see you are using a toolBar and not a tabBar. Even better would be to create a custom content view controller.
You should be looking into using containment:
UIViewController containment
How does View Controller Containment work in iOS 5?
positioning UIViewController containment children
check out the docs
I placed a UISegmentedControl programmatically on the screen (stand-alone, not as part of a navigation bar) and set its autoresizingMask to UIViewAutoresizingFlexibleLeftMargin because I want it to stick to the right.
However, when I rotate the screen the control stays in its original position and does not move to the right (or anywhere else for that matter).
I also tried all other possible values (and some combinations) for the autoresizingMask, but the thing doesn't move at all.
Other elements on the screen with the same setting move correctly.
I do not have a XIB for this view controller, but I tried to place a similar segmented control temporarily in another XIB, and when I set the struts correctly it did move as expected.
What am I doing wrong?
In your view controller's viewDidLoad method place the following log statement:
NSLog(#"%#", [self.view recursiveDescription]);
This will log out your view controller's view hierarchy. If it's not clear from the log where the issue is, then please add the log to your question so we can help further.
I am new to UITableView, so please don't mind me asking the following silly question(s).
In the attached screenshot, the IB's geometry does not match the geometry on the simulator - notice the white bar at the bottom of the screen in the simulator. What did I miss? The outlets for the TopLevelView, TableView and the DatePickerView are defined in the rootViewController.h file.
In the IB, I had set the background color of the TopLevelView to lightBlue; the background color of the tableView is set to ClearColor in the rootViewController.m file. But, the lightBlue color of the TopLevelView is not shown around the edges of the TableView.
[ivTableView setBackgroundColor:[UIColor clearColor]];
See the screenshot here
Regards, Sam
The "white bar at the bottom" problem suggests that you've got a view controller that doesn't seem to know that it's inside a navigation interface. You should show the code or otherwise describe how you're assembling this interface, because there's something wrong in how you're doing it.
The root view controller of your entire interface, the one whose view appears as the sole immediate subview of the window, should be a UINavigationController. Its rootViewController should be the view controller that fetches this view from the nib. Beyond that it's hard to help without knowing more about what you're doing.
I suggest that you start with the Navigation template. Unfortunately its RootViewController is a UITableViewController, which isn't going to work here because that's only for the case where the table view occupies the entire interface. So turn the RootViewController into an ordinary UIViewController. Now in the RootViewController.xib design the interface you've drawn above. It should load properly, convincing you that you're on the right track.
My app has a welcome screen that can only be shown in portrait mode. After the user has tapped through the welcome screen I'd like to show another screen that can be used in both portrait mode and landscape.
I have set up a view controller that implements shouldAutorotateToInterfaceOrientation: returning YES only for UIInterfaceOrientationPortrait, and I add the view to the window with [window addSubView:view]. I tag this view with the tag 1.
When the user taps through the welcome view and the app moves on to the new view I do:
[[window viewWithTag:1] removeFromSuperView];
[window addSubView:myViewController.view];
Where myViewController is an instance of the 2nd view's view controller (that handles the shouldAutorotateToInterfceOrientation method properly).
Now when I rotate, it still calls shouldAutorotateToInterfceOrientation on the original view's view controller, and does not call it on the new view's view controller.
This note from Apple says that only one view controller will get rotation notifications; however, I have removed the other view controller.
What am I doing wrong?
actually that note doesn't say that "only one view controller will get the notifications" but instead it says that "Only the first view controller added to UIWindow will rotate.".
So this might be the problem.
To resolve it, i would say to always have a view added to your window (call it permanent), and add your welcome screen and the next views to this permanent view.
Hope this helps.
as the note you link to state:
Only the first view controller added
to UIWindow will rotate.
So put a flag that makes sure that shouldAutorotateToInterfceOrientation returns NO until the user have dismissed the screen - and then returns YES afterwards. This is a simple and working solution - however, from a code readability point it might be confusing that a "dismissed" view actually controll the rotation.
Personally; my experience is that it's not really worthwhile having some views rotating and some don't - and users tend to don't like it.
happy coding
I wrote up a quick test that shows what you are trying to do should work. Here are the basics I did:
Create two view controllers. App starts with the first view controller being set in the AppDelegate into an instance variable viewController through NIB files. It is then added to the window as you have written.
I then setup an action that when called (could be a Timer, button on first view controller, etc.) that performed the following:
Remove view using [self.viewController removeFromSuperview]. This is different than the way you have done with the tag.
Created second view controller and assigned it to self.viewController.
Added to window like you have specified.
Not sure what is incorrect with your code. I would guess that perhaps the first view wasn't really being removed.
Hey everyone, running into a bit of an issue,
I have created all my views through IB, with the main window having a NavigationController, and a TabBarController which loads a TableViewController in its first tab.
The problem happens when i use the searchbarcontroller in the navigation controller, everything works fine with the exception that when the navigation bar at the top disappears, the table expands too high, and i can't figure out what im doing wrong.
Attached is an image of what im referring to, any help would be greatly appreciated.
alt text http://img263.imageshack.us/img263/4706/picture1ot.png
Some more information:
i have my MainWindow with a UINavigationController, and a UITabBarController. On the first Tab, i have it loading another nib "AVN_TableController" which is a UITableViewController nib, with the Searchbar delegate.
If you've set your view sizes correctly in Interface Builder and are using the "Simulated Interface Elements" to cause the status bar, navigation bar, and tab bar to display, it should work correctly. If not, then what comes to mind is this issue where displaying an action sheet has it's tappable rectangle offset by the height of the tab bar because it is added to the wrong view. Not sure if that would apply here, but it's at least something to consider.
I ended up going the route of creating my own tabbarcontroller, as that was causing the issue.