My Main Window will not change even though I change it? - ios4

Hey!
Have a problem that is driving me crazy! My Main Window will not change when a make changes in interface builder in xcode 4, I have played around for over 2 hours trying to make changes but when a build it does not change. When a change something in the code it works just fine.
The thing I'm trying to add to the main window is a new tab in the tabbar.
Please help me !
UPDATE:
My applictiondidfinfishwithoptions looks like this.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
[window addSubview:navigationController.view];
[window addSubview:tabBarController.view];
[self.window makeKeyAndVisible];
return YES;
}

Make sure that you are adding the tab to whatever view is assigned to the main window's root view controller property. If you drag and item into the window itself it won't work. To complicate matters, some of Apple's templates configure the root view controller in the application delegate's application:didFinishLaunchingWithOptions: method, so check there to see what is being assigned.
UPDATE:
You should add one view to the window and add the other views as subviews.

Related

Custom UINavigationItem disappears on pushViewController

I am running into a weird issue with a custom UINavigationItem disappearing when I push a viewcontroller. Here's my setup:
RootViewController is UITabController
UITabController
Tab1->CustomNavController->ViewController1
Tab2->CustomNavController->ViewController2
Tab3->CustomNavController->ViewController3
I have a custom UINavigationItem (with rightBarButtonItems) that I push on to the CustomNavController for all the tabs. Everything works fine with the first level view controllers on the tabs.
The problem occurs when I push a new ViewController (say VC4) on to a ViewController (say ViewController3) - either via a segue push or through pushViewController with a custom nib.
The custom navigation item disappears and the only way I seem to get it back is to customize the self.navigationItem in VC4 - which I don't want to do.
Any ideas and help is greatly appreciated.

What must be done to migrate from Storyboard back to XIBs for iOS 4.x support?

I have seen scattered information related to this subject across stackoverflow and other sites, but nothing comprehensive. I've wasted hours upon hours trying to get this to work to no avail. However, I see in this post on stackoverflow (http://stackoverflow.com/questions/7909906/extracting-nibs-xibs-from-storyboards-ios), but nothing with step by step details.
I have only a single view controller (HomeViewController) in my storyboard, and it is extended from a navigation controller.
Can someone please help me identify exactly what all needs to happen to make this work?
Please correct me, add to, etc to make these steps correct:
Create a new XIB (say, HomeViewController.xib)
Copy all items from the storyboard's view controller into this xib
Set the Class type for the view controller to be HomeViewController class.
Hook up all of the IBOutlets and IBActions.
?? - Should I make the xib contain a navigation controller which contains the UIViewController, or should I set the File's Owner to the HomeViewController class??
Add new Window property in the AppDelegate class.
Create a new MainWindow.xib. What setup needs to happen here? (a) File's Owner to UIApplication; (b) Drag new Object to the "Objects" panel and set it's class to my AppDelegate class; (c) Drag new Window to the "Objects" panel; (d) Connect the IBOutlet for the AppDelegate Window property to this new window object.
Go to the project settings (click on the project in the Project Navigation tab, select the target), and clear the "Main Storyboard" field and set the Main Interface to what? HomeViewController? Or Main Window?
Make the change in the AppDelegate class as shown below:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
//self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
This is all I know to do, but it still doesn't work. What am I missing?

White Screen during loading the ViewBasedApplication in iphone

I am new to iPhone. I have Develop one aplication that is of ViewBased Application.
Everything is right but while i run the application, instead of showing list of content it shows the white screen. After doing studies come to know that it may be for the XIB file references. As my code is right at all. So will u tell me while it appear like it ?
Thanks in advance.
check your .xib file and see whether you have link it to datasource and delegate or not.
Check your xib and properly check inteface builder that a datasource and delegate is set or not. for showing a view you have to set datasource and delegate..and also you have to check in appdelegate file that a object of your view controller have been made or not... i.e. you have to allocate memory of your view controller in app delegate file..

iPad: Correct approach to custom navigation items in UINavigationController

This relates to a question I asked a few days ago: iOS: Setting text in nib subview from view in UITabBar/UINavigationController application
I need to put the search bar and buttons on the top right of a navigation controller, this is more than the standard single button that UINavigationController.navigationItem.rightBarButtonItem allows so I am using the initWithCustomView: method of UIBarButtonItem to load a view from a nib file.
In my particular case, i've put the view as a seperate item in the main view file for that form
The problem i've got is load and display sequence and I wanted to know if this was the right approach to this?
It seems that the following happens:
viewDidLoad on my main window gets called
viewDidAppear on my main window gets called and I set up rightBarButtonItem
I then want to populate a text field on that search bar but because the loading of the view for the button item happens in the main thread, I don't know when it's appeared.
Would I be better to create a new class with nib for the search bar and buttons which would then have a viewDidLoad/viewDidAppear and I could then create a delegate function so I could 'deQueue' the text to go into the search bar?
Or, am I missing something really simple?

UIScroller inside UIWebView

Does any one have an idea how to access the UIScroller class , which is the default subview of UIWebView ?
I want to handle the touches, zooming , panning and scrolling features inside the webview .
Thanks..
I know this thread is old but if anyone comes across it there's a new way.
As of iOS 5 UIWebView now has a property called scrollView which you can't replace but you can set the properties of it. Most people just want to disable zooming/bouncing/scrolling all together which can be done by setting the properties of the scrollView for example if webview is a UIWebView:
webview.scrollView.bounces = NO; //Disables webview from bouncing
webview.scrollView.minimumZoomScale = webview.scrollView.maximumZoomScale = 1.0; //Forces zoom to be at 1 (can be whatever you fancy) and disables zooming
webview.scrollView.bouncesZoom = NO; //Disables bouncing when zooming exceeds minimum or maximum zoom
I suppose you could set the delegate for the scrollView if you want more control, though to be on the safe side you might want to store the original delegate and call its methods appropriately in your custom delegate.
Handling the touches would be more difficult since you can't replace the scrollView to provide your own handlers. Best you could do is add some gesture recognizers as part of the UIView and try to handle them there, but I think UIWebView will still receive the events. Alternatively in iOS 5 they let you access the gesture recognizers directly on UIScrollView.
You can find this by going like this:
[webview objectAtIndex:0]
That should be where it is. If not, put this in your code somewhere and run the program to search for the index of the UIScroller, and replace the 0 above with that index:-
for (UIView *subview in [webView subviews]){
NSLog(#"subviews of webView : %#", [[subview class] description]);
}

Resources