UIActivityIndicatorView is not working (getting Facebook permissions affecting UIActivityIndicatorView) - iphone

I have a tabbarcontroller with three tabs/viewcontrollers.
When I first start my app, with my ActivityIndicator set to be visible and animated - courtesy of interface builder - it works fine.
However when I click a button an internet window opens to Facebook in order to get the user's permission.
Once the Facebook part is taken care it returns to my app but the ActivityIndicator is not longer animated - it is still visible though, just frozen.
If I switch to another tab/viewcontroller and then come back to the tab/viewcontroller with the ActivityIndicator everything works fine.
Is there a way to refresh my ViewController so that I don't have to programmatically make the ViewController switch back and forth? Or any other suggestions?
/* I searched the forums and I saw a similar question. It appeared that there was a broken connection. Therefore I'll include the code where I add the ViewController (i.e., "controller" to my tabbarcontroller). */
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
controller = [[DemoAppViewController alloc] init];
controller.view.frame = CGRectMake(0, 20, 320, 460);
controller.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"movieAppBackground.jpg"]];
MyTabBarViewController *vc2 = [[MyTabBarViewController alloc] init];
SecondViewController *vc3 = [[SecondViewController alloc] init];
controller.title = #"Intro Screen";
vc2.title = #"Explore";
vc3.title = #"Send a Pic";
UITabBarController *tbc = [[UITabBarController alloc] init];
tbc.viewControllers = [NSArray arrayWithObjects:controller, vc2, vc3, nil];
self.theTBC=tbc;
[controller release];
[vc2 release];
[vc3 release];
[tbc release];
[self.window addSubview:tbc.view];
[self.window makeKeyAndVisible];
return YES;
}

whereever u have used NIB file to show with viewcontrollers u have to create them with initwithname
Example
SecondViewController *r=[[SecondViewController alloc]initWithNibName:#"SecondViewController" bundle:nil];
like this change whereever u have used nib file to create instance,
i meaned for all custom viewcontrollers u have created with NIB file

Related

issue in DDMenuController menuViewController like facebook

My First Question
DDMenuController(facebook split menu) Must be on RootviewController? it can not be on other viewController which we push on rootViewCotroller?
if answer is no then
Second Question
i am trying to make split viewController like facebook for that i am using this sample
https://github.com/devindoty/DDMenuController
now what i want to do is i dont want set DDMenuControl as rootviewcontroller in appdelegate in my rootcontrollers there are view buttons which push my all other ViewController
so what i want is from my rootViewController' Buttons i push another controller and then that view should get pushed and same time there should be DDMenuController too
so what will happen is on navigation bar there wont be back button there will be splitting screen button like facebook and from there i can go to another view controller
now let me tell you what i have achieved so far my rootViewController is getting displayed and then from there i push my other ViewController and on navigation bar splitting button is also getting displayed but its not working let me should you code to make this all clear
this is how i set my rootViewContoller in app delegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary
*)launchOptions
{
FirstPadViewController *mainController = [[FirstPadViewController alloc] init];
navController = [[UINavigationController alloc] initWithRootViewController:mainController];
self.window.rootViewController = navController;
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
so it get displayed with some buttons from where i can push my other viewController
this is how i push my other ViewController
- (IBAction)goToCamera:(id)sender {
AROverlayPadViewController *svController = [[AROverlayPadViewController alloc] init];
[self.navigationController pushViewController:svController animated:YES];
[svController release];
svController = nil;
}
so AROverlayPadViewController is getting pushed
and in AROverlayPadViewController's viewWillAppear this is what i do for achieving splitting screen like facebook
-(void)viewWillAppear:(BOOL)animated{
DDMenuController *rootController = [[DDMenuController alloc] initWithRootViewController:self];
LeftController *leftController = [[LeftController alloc] init];
rootController.leftViewController = leftController;
}
splitting button is getting displayed but when i press it is not working
now i really dont have any clue what to do any help will be highly appreciated
Answering the first question: actually it's a yes. This is how you do it, in the method that sends you to your nextScreen:
-(void) goToAnotherController {
OtherViewController *nextScreen = [OtherViewController alloc] init];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:nextScreen];
DDMenuController *menuController = (DDMenuController*)((AppDelegate*) [[UIApplication sharedApplication] delegate]).menuController;
[menuController setRootController:navController animated:YES];
}

Parent view is not displayed after the low memory warning is received during MFMailCompose modal is open, canceled and draft saved/deleted

I have the following structure on my iPhone app
AppDelegate / UITabBarController / 5 UINavigationControllers(My tabs) / UIViewController(like rootViewController for each UINavigationController)
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
HomeViewController *homeViewController = [[HomeViewController alloc] init];
GoalsTableViewController *goalsTableViewController = [[GoalsTableViewController alloc] init];
HistoryViewController *historyViewController = [[HistoryViewController alloc] init];
SettingsViewController *settingsViewController = [[SettingsViewController alloc] init];
InfoViewController *infoViewController = [[InfoViewController alloc] init];
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.delegate = self;
self.navBarActivity = [[UINavigationController alloc] initWithRootViewController:homeViewController];
self.navBarSettings = [[UINavigationController alloc] initWithRootViewController:settingsViewController];
self.navBarHistory = [[UINavigationController alloc] initWithRootViewController:historyViewController];
self.navBarGoals = [[UINavigationController alloc] initWithRootViewController:goalsTableViewController];
self.navBarAbout = [[UINavigationController alloc] initWithRootViewController:infoViewController];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:self.navBarActivity, self.navBarGoals, self.navBarHistory,self.navBarSettings, self.navBarAbout, nil];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
return YES;
}
In some UIViewControllers I implemented a MFMailComposeViewController in order to send emails.
I experimented a weird issue (reproduced on simulator and real devices iOS 5.0 and 5.1)...
Using an iPhone Simulator (only iOS 5.0 or 5.1), if I simulate a low memory warning while a MFMailComposerViewController modal is open on the screen and then tap on Cancel and then tap on Delete|Save draft, when the modal is dismissed the parent view seems not visible (blanked view).
The life cycle seems work fine due, if I follow the same steps but after simulate a low memory warning I send the email from MFMailComposeViewController modal, when modal is dismissed, my parent view looks fine.
Any suggestions how to prevent my parent view from being unloaded on memory warning?
Edit1
I figured out what is happening, after unloading and comeback to the view and entering the last view within viewdidload(life cycle), the tabBar is not inserting navigation view. I check the subviews of tabBar:
UITransitionView
==><UIViewControllerWrapperView>
==> empty
<UITabBar>
I reintegrated the view of navigationBar by adding as subview in viewdidload:
UIView *tabBarControllerWrapperView = [[[self.tabBarController.view.subviews objectAtIndex:0] subviews] objectAtIndex:0];
// tabBar UIViewControllerWrapperView has not views
if([tabBarControllerWrapperView.subviews count] == 0)
{
// add navigationbar view
[tabBarControllerWrapperView addSubview:self.navigationController.view];
}
There is no better way to fix it, any thoughts?
After a memory warning is possible that on the non visible controllers is called viewDidUnload (iOS <= 5 ).In your case the view of the controller that presented the modal mailcomposer was probably unloaded.
The idea behind viewDidUnload is that you save the data you need to restore the view once viewDidLoad is called again. What you have to keep in mind is that your viewDidLoad can be called multiple times.
On iOS6 viewDidUnload is not called anymore, so this logic must be moved to didReceiveMemoryWarning

rootViewController property does not work on iOS 5 project with xcode 4.2

Hi I just started experimenting on iOS 5. I created a project without storyboard and trying to add views programmatically (no use of interface builder at all). I have following code but rootViewController property of the window does not seem to work. I did NSLog on self.tabController and it shows me value(not null) but on the other side when after self.window.rootViewController = self.tabController, i output self.window.rootViewController it gives me null in console.
I have been struggling with this issue for a long time now. Any help would be appreciated.
Following is my didFinishLaunching method:
self.dataSource = [[[ADJWebDataSource alloc] init] autorelease];
ADJBrowseListingsViewController *browseListingsVC = [[ADJBrowseListingsViewController alloc] init];
ADJSecondViewController *secondVC = [[ADJSecondViewController alloc] init];
tabBarController = [[UITabBarController alloc] init];
tabBarController.view.frame = CGRectMake(0, 0, 320, 460);
navController = [[UINavigationController alloc] initWithRootViewController:browseListingsVC];
NSMutableArray* viewControllers = [[NSMutableArray alloc] initWithCapacity:2];
[viewControllers addObject:browseListingsVC];
[viewControllers addObject:secondVC];
[navController release];
[browseListingsVC release];
[secondVC release];
tabBarController.viewControllers = viewControllers;
[viewControllers release];
browseListingsVC.dataSource = self.dataSource;
NSLog(#"controller %#", self.tabBarController);
self.window.rootViewController = self.tabBarController;
NSLog(#"controller1 %#", self.window.rootViewController);
[self.window makeKeyAndVisible];
return YES;
Thanks
Vik
When you are using story board, why are you still creating objects for view controllers?
You can directly prepare the flow of your views in story board, add necessary segues etc.
If your view controller is floating (without any segues), you have to use the method "instantiateViewControllerWithIdentifier" in story board class.
For a view controller if you want to add navigation in story board, select the view controller, go to menu "Editor"->"Embed in" and select navigation controller. It will add navigation controller to your view controller.
Figured it out with the help of Firoze. Actually, I had to allocate and initialize self.window programmatically. I was confused as I never had to do that in iOS 4 or earlier. But then I just realized prior to iOS5, every project has a MainWindow.xib which had self.window allocated and initialized, now if I am not using storyboard in iOS5, there is no .xib file, I needed to allocate and initialize it myself in the code

options for TabBar/UITabBarController implementations

I am new to xcode and trying to understand how UITabBarController works. I have been looking everywhere and could not find a straight solution to this question. In the majority of the examples/tutorials that I see, the UITabBarController is defined in the AppDelegate, and then once you launch the app, you see the tab bar right away. In my app, I want to show a welcome screen first, then once you click "Enter" you get to the tabbar view. So the ideal structure of my objects will be the following:
MyProjectAppDelegate --> MyProjectViewController --> FirstView / SecondView
As far as my understanding, nothing tabbar related should then be declared in MyProjectAppDelegate with this structure. I tried to look at some examples where the UITabBarController is declared in the AppDelegate and do the same in the MyProjectViewController, but nothing happens.
For example, I did this in my MyProjectViewController within an IBAction that is connected to the "Enter" UiButton on my welcome screen:
- (IBAction) EnterApp {
[window addSubview:tabBarController.view];
tabBarController = [[UITabBarController alloc] init];
tabBarController.delegate=self;
FirstView* first = [[FirstView alloc] init];
UINavigationController *firstNav = [[UINavigationController alloc] initWithRootViewController:first];
SecondView* second = [[SecondView alloc] init];
UINavigationController *secondNav = [[UINavigationController alloc] initWithRootViewController:second];
NSArray* controllers = [NSArray arrayWithObjects:firstNav,secondNav, nil];
tabBarController.viewControllers = controllers;
[window addSubview:tabBarController.view];
}
Again, this did not do anything once I clicked on the "Enter" button, even though it does the job in the example where I took it from (where it's within the AppDelegate)
I also tried this on my MyProjectViewController, where the tabbar did show up on the First/Second view, but with no option to customize it (just blank black bars with nothing on them and no idea where to configure them):
- (IBAction) EnterApp {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
UIViewController *viewController1 = [[FirstView alloc] initWithNibName:#"FirstView" bundle:nil];
UIViewController *viewController2 = [[SecondView alloc] initWithNibName:#"SecondView" bundle:nil];
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2, nil];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
}
What went wrong here and what should be the right way to go about doing that? A quick example would be highly appreciated.
Thanks!
I have something similar in one of my apps. At first launch it shows a login screen. After the user successfully logs in, the app switches to a tab bar controlled view.
I do the switching in my appdelegate. The login view sends a notification which the app delegate observes and rebuilds the screen:
- (void)switchView:(NSNotification *)notification {
MyTabbarView *homeView = [[MyTabbarView alloc] init];
NSArray *controllers = [NSArray arrayWithObject:homeView];
[mainNavController setViewControllers:controllers animated:YES];
mainNavController.navigationBar.barStyle = UIBarStyleBlack;
mainNavController.navigationBar.hidden = NO;
[homeView release];
}

How to show UINavigationController on view

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// Add the view controller's view to the window and display.
[window addSubview:viewController.view];
MainPageDialog *overviewViewController = [[MainPageDialog alloc] initWithNibName:#"MainPage" bundle:nil];
UINavigationController *nav_obj = [[UINavigationController alloc] initWithRootViewController:overviewViewController ];
[self.viewController presentModalViewController:nav_obj animated:YES];
[overviewViewController release];
[self.window makeKeyAndVisible];
return YES;
}
This code shows the blue bar of navigation controller, but no buttons on it.It seems like to be that the UINavigationController allocated as empty.
Who knows what problems is?
UPD:Archive http://www.mediafire.com/?lbjjvl6fcue2q18
Please help me, I'm new in objective-c
You need to create the button for it, for example:
UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:launcherView action:#selector(endEditing)];
self.navigationItem.leftBarButtonItem = doneButton;
[doneButton release];
The correct way to use a UINavigationController is to push view controllers on to it. That way they will be stacked and the navigation bar will be populated with a back button when it is case (i.e., when you can actually go back to a previous controller). You control the label that appears in the "back" button by defining the title of the controllers you push.
The technique shown in another answer (setting explicitly the button) is useful with defining the right button, if you ever need one.
You could try with this code:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
MainPageDialog *overviewViewController = [[MainPageDialog alloc] initWithNibName:#"MainPage" bundle:nil];
UINavigationController* navigation = [[UINavigationController alloc] init];
[navigation pushViewController:overviewViewController animated:NO];
[overviewViewController release];
[window addSubview:[navigation view]];
[self.window makeKeyAndVisible];
return YES;
}
Instead of doing:
UINavigationController* navigation = [[UINavigationController alloc] init];
[navigation pushViewController:overviewViewController animated:NO];
you could also use initWithRootController, but to display the general case of how you push a view controller I preferred this one.
Notice that since you are pushing just a root controller, you should see no back button at the moment, but if you push a second view controller, then it will appear.
EDIT: I gave a look at your project. Summary of what you should try and do:
objects you need in your NIB: File's Owner (UIApplication), First Responder, FBFun App Delegate (iVkAppDelegate), Window (UIWindow); remove the rest;
File's owner delegate outlet is FBFun App Delegate;
FBFun App Delegate window outlet is Window.
With this simple setup (more or less what you have), use this code :
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
UINavigationController* navigation = [[UINavigationController alloc] init];
//-- MainPageDialog *overviewViewController = [[MainPageDialog alloc] initWithNibName:#"MainPage" bundle:nil];
iVkViewController *overviewViewController = [[iVkViewController alloc] init];
overviewViewController.title = #"First";
[navigation pushViewController:overviewViewController animated:NO];
iVkViewController *overviewViewController2 = [[iVkViewController alloc] init];
overviewViewController2.title = #"Second";
[navigation pushViewController:overviewViewController2 animated:NO];
[overviewViewController release];
[window addSubview:[navigation view]];
[self.window makeKeyAndVisible];
return YES;
}
In the code above, as you notice, I instantiated twice your iVkViewController just to have a second controller to push onto the navigator.
Please, delete your existing app from the simulator, and the run this in order to see that the navigation bar is correctly created and you can go back from the second controller to the first one.
I removed usage of MainPageDialog, because the MainPage nib has many problems.
But I hope this skeleton is sufficient for you to go forward with your development.
You had missed the line as you are not adding view to window.Add this line in your code
[window addSubview:nav_obj.view];