I have an iPad application compatible with iOS 5.1 or higher. I'm updating the app for iOS 7.
I have this problem: I have a UINavigationController inside a UITabBarController. I want to add rightBarButtonItems. With iOS 6 or lower are seen, but with iOS 7 no. What I'm wrong?
PS: I'm forced to make app compatible with iOS 5.1 because there are some customers who are still using the first generation of iPad, so I can't use AutoLayout. I'm XIB because the project is a pretty old and I haven't to rewrite code.
Thank you!!
edit for Nikos M.
self.navigationItem.rightBarButtonItems = #[...];
Image: http://i.stack.imgur.com/RB3Rc.png
Edit 2:
I had tried to add a custom view on navigation bar:
//I added this line otherwise I not see the Navigation Bar!!
[self.navigationController.navigationBar setFrame:CGRectMake(0, 0, 320, 132)];
[self.navigationController.navigationBar addSubview:[self addTableHeader]];
and this is the result!!
http://i.stack.imgur.com/aksqb.png
This is working for me in iOS 7. Try this.
self.navigationItem.rightBarButtonItems = [NSArray arrayWithObjects:[[UIBarButtonItem alloc]initWithTitle:#"ONE" style:UIBarButtonItemStylePlain target:self action:nil], nil];
Related
My app is made with cocos2D 2.1, and I am using Xcode 5. After compiling, the UINavigationBar appears in my app on the top.
How can it be hidden? I have tried the other generic iOS 7 codes that seem to work for native iOS 7 Apps:
// None of the following works
navController_ = [[UINavigationController alloc] initWithRootViewController:director_];
navController_.navigationBarHidden = YES;
navController_.edgesForExtendedLayout = UIRectEdgeNone;
[navController_.navigationBar setTranslucent:NO];
if ([[CCDirector sharedDirector] respondsToSelector:#selector(edgesForExtendedLayout)])
[CCDirector sharedDirector].edgesForExtendedLayout = UIRectEdgeNone;
Set UIViewControllerBasedStatusBarAppearance to NO in the project's Info.plist.
Add this(with spaces) to your info.plist:
View controller-based status bar appearance -> Value: NO
How do I hide my back button on iOS 7?
I tried replacing it:
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:homeButton];
and hiding it:
self.navigationItem.hidesBackButton = YES;
Both used to work but don't anymore on devices using iOS 7
Any help?
Thanks
I am compiling my app with iOS 6.1 SDK and deploying in a iOS7 device. The app's device is set for iPhone only.
I have a view controller that I add to a navigation controller.
self.window.rootViewController = [[UINavigationController alloc]
initWithRootViewController:
[[MyViewController alloc] init]];
When I deploy the app in iPad Mini running iOS 7, there is a strange gap shown at the top.
If I set the app's device to Universal, then the gap goes away. Is there any explanation for this? Thanks.
The few changes which you should take care of in iOS 7:-
1) Navigation Bar of iOS 7 is of dimension :- 320 X 64 while iOS 6 it is :- 320 X 44.
2) Navigation Bar Translucent Property is YES by default in iOS 7 so set it to NO, as status bar is also included in iOS 7.
Take care of these things and it would go fine.
// Sample Code of setting the navigation controller and image programatically in iOS 7
self.navigationController.navigationBar.translucent=NO;
[self.navigationController setNavigationBarHidden:NO animated:YES];
UIImage *backgrdNavImage=[UIImage imageNamed:#"abc.jpg"];
[self.navigationController.navigationBar setBackgroundImage:backgrdNavImage forBarMetrics:UIBarMetricsDefault];
I just updated my phone to IOS 6 but I have some issue regarding adding UIImageView on the UINavigationController navigationbar. This is my code
UIImage *logoImage = [UIImage imageNamed:#"navigationbar.png"];
UIImageView *logoImageView = [[UIImageView alloc] initWithImage:logoImage];
UINavigationBar *navBar = self.navigationController.navigationBar;
[navBar addSubview:logoImageView];
[logoImageView release];
This will add logo on navigationbar, it works great on the lower version of IOS 6. But on IOS 6 the logo shown but the back button was behind the logo so back button is not shown.
I don't want to override the UINavigationBar drawrect since I also have UINavigatioBar somewhere on the code for popup.
Any suggestions?
I think you don't need a UIImageView in IOS 6.
You can just put a background image in the UINavigationBar (for example in AppDelegate) like this:
[[UINavigationBar appearance] setBackgroundImage :[UIImage imageNamed:#"navigationbar"]];
Found a good site which explains some new user interface customisation in IOS 6:
click here
I'm using MPMoviePlayerViewController - with the player controls set to: MPMovieControlStyleFullscreen
I'm having a problem with some of buttons that are in MPMovieControlStyleFullscreen: forward, reverse, and fullscreen (the one with the arrows pointing at eachother).
I would like to either remove the forward, reverse, and fullscreen buttons or control what they do when the user taps them.
Thank you!
There isn't a way to customize the MPMovieControlStyle values provided by Apple. What you need to do is is turn off the Apple controls (MPMovieControlStyleNone) and then create your own custom controls. Apple is fine with you putting your own UIViews in to the hierarchy here, so you can get started with something like this:
MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL: YOUR_URL];
moviePlayer.controlStyle = MPMovieControlStyleNone;
UIView *movieView = moviePlayer.view;
[movieView addSubview: _movieControlsView];
[movieView bringSubviewToFront: _movieControlsView];
Where _movieControlsView was set up earlier in code or in IB.
Aesthetically, you can do what you want, but I would recommend sticking with something that looks like Apple's choices so as not to confuse the user. For the project I just finished, I created a transparent button the exact size of the movie player. Clicking the button fades in a control bar on the bottom with my custom controls. If one of the controls isn't clicked, the control bar fades back out again after a few seconds.
First off, MPMoviePlayerController is a little different than MPMoviePlayer*View*Controller, so some of these answers lead to problems when converting applications that were built in an iOS 4.3+ environment.
I've built some apps using MPMoviePlayerController that worked fine when built in iOS 3.2. When I rebuilt it with XCode 3.2.6, (iOS 4.3), the videos don't even play on the iPhone. I since fixed that by adding the MPMoviePlayerController instance to a subView, then presenting a modal (Player is a UIViewController) with the movplayer in fullScreenMode:
//from didSelectRowAtIndexPath
Vid *selected = [items objectAtIndex:position];
player = [[Player alloc] init];
movplayer = [[MPMoviePlayerController alloc] initWithContentURL:selected.vidURL];
movplayer.view.frame = player.view.bounds;
movplayer.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight |
UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin |
UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin;
[player.view addSubview:movplayer.view];
[self presentModalViewController:player animated:YES];
[movplayer setFullscreen:YES animated:NO];
[movplayer play];
[player release];
//movplayer is released inside - (void)exitedFullscreen:(NSNotification*)notification
This was done on account of the UINavigationBar being half cut off when rotating.
When I got to the iPad version of the app the modal option wouldn't work aesthetically. It was also having the UISplitViewController navBar and toolbars half cut off when rotating in full screen mode. So I tried implementing MPMoviePlayerViewController instead of MPMoviePlayerController. With this conversion, XCode gave me errors when trying to set:
movplayer.controlStyle = MPMovieControlStyleEmbedded;
The proper way to do this with a MPMoviePlayerViewController is:
movplayer.moviePlayer.controlStyle = MPMovieControlStyleEmbedded;
When the player is added as a subView, the pinch gestures will toggle the player between fullScreen and the size of your parentView (player.view.bounds) smoothly, as well as preserve the toolbars and navBars native to the parent.
//iPad version with a view (viewForMovie) inside the DetailViewController
movplayer = [[MPMoviePlayerViewController alloc] initWithContentURL:[current vidURL]];
movplayer.moviePlayer.controlStyle = MPMovieControlStyleEmbedded;
movplayer.view.backgroundColor = [UIColor clearColor];
movplayer.view.frame = viewForMovie.bounds;
[viewForMovie addSubview:movplayer.view];
So these two examples show some workarounds for those who want to convert their iPhone or iPad apps to a newer iOS version.
Try setting MPMovieControlStyle of your MPMoviePlayerController object to MPMovieControlStyleNone