Hide the tabBar in Rubymotion - rubymotion

I am building an iOS app in Rubymotion. I want to create a custom tabBar so I need
to use a real tabBar but hide it. How can I hide the tabBar in Rubymotion?

To hide the tab bar you can use hidesBottomBarWhenPushed.
The Objective C is:
MyController *myController = [[MyController alloc]init];
myController.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:myController animated:YES];
[myController release];
Therefore the RubyMotion Code is
#my_controller = MyController.alloc.init
#my_controller.hidesBottomBarWhenPushed = true
self.navigationController.pushViewController(#my_controller, animated:true)
I hope this helps. If you'd like to see more references to tab bars please check:
https://github.com/IconoclastLabs/rubymotion_cookbook/tree/master/ch_2/12_tabbars
Or if you'd like to see basics of navigation controller please check
https://github.com/IconoclastLabs/rubymotion_cookbook/tree/master/ch_2/11_navbarbuttons
I hope this helps!

Related

Navigation view is hiding while pushing from SwiftUI views to Storyboard project in iOS13

I have added SwiftUI views in my existing swift project.
I have the following flow in the project
FirstViewController --NavigationPush -> SwiftUIView1 -NavigationLink->
SwiftUIView2 - NavigationLink-> SwiftUIView3 - NavigationLink
(UIViewRepresentable) -> SecondViewController.
till SwiftUIView3 everything works as expected. while pushing from SwiftUIView3 -> SecondViewController, even though I'm setting the navigation property isHidden = false,
the navigationBar appears in the controller for a fraction of sec and disappears. I have tried to unhide navigation in all the controller life cycle methods. But nothing happens. Please let me know your suggestion to resolve this.
FYI, below code, I used SwiftUI to hide the navigation bar.
Code Block
.navigationBarTitle("") // This should be empty.
.navigationBarBackButtonHidden(true)
.navigationBarHidden(true)

Titanium Hyperloop casting ListView to UIScrollView to use flashScrollIndicators

I want to flash the scrollbars of a ListView in Axway / Appcelerator Titanium. So I cast a Titanium ListView to a iOS UIScrollView and then try to call the flashScrollIndicators method on it, but I get an exception. Does anyone now how to accomplish this? See my code below:
-- View
<Alloy>
<Window onOpen="onWindowOpen">
<ListView id="listView">
etc...
-- Controller
// After displaying the ListView I call:
var UIScrollView = require('UIKit/UIScrollView');
var listView = UIScrollView.cast($.listView);
listView.flashScrollIndicators();
The $.listView object is natively a subclass of UIView, not a UIScrollView. It contains a UITableView as a child view. You could access the tableview like this:
var UIView = require('UIKit/UIView');
var listView = UIView.cast($.listView);//you cast it to be able to access it's native properties
listView.tableView.flashScrollIndicators();
Haven't tested it but I guess it should work.
When in doubt about the type of a Titanium UI element, just go and check the source code by opening the project compiled in the build/iphone directory. Open it with XCode and search for the header file.

How to setUp UiTableViewController below the battery bar

newBie here. I have added an UItableViewController into storyBoard. I use this as a setting page.
HomeVC ----> Setting VC
In code : I use the below code to bring the tableView below the battery Bar:
self.tableView.contentInset = UIEdgeInsets(top: 20,left: 0,bottom: 0,right: 0)
Problem:
How to move the TableView down below the battery bar so that I can add a button above the table in StoryBoard
Please help.
For this you should use a normal view controller and drag a table on the view controller this way you can make the table size whatever you like. This will also allow you to place buttons wherever you like.
Don't forget to assign the TableViewDataSource and TableViewDelegate to your view controller.
Good luck!
After doing some search on UiTableViewController, to use it as setting page I have to set static cell to it. This UiTableViewController will occupy the entire view.
To set the tableView below the battery icon,
use:self.tableView.contentInset = UIEdgeInsets(top: 20,left: 0,bottom: 0,right: 0)
However, No need to do so. In the first TableViewSection, you can create a few tableView cell, just leave the first cell blank which acts as a margin below the battery bar.

Status bar won't disappear

I'm creating an application and I want the status bar hidden. When I test the app, the status bar is hidden whilst the splash screen is shown, but once the app is fully loaded, the status bar reappears.
I'm using Xcode 5 and iOS 7, and have tried disabling the status bar programatically
([[UIApplication sharedApplication] setStatusBarHidden:YES
withAnimation:UIStatusBarAnimationFade];),
in the info.plist file, and using the attributes inspector on the .xib file. Nothing appears to work.
Any ideas?
Try adding the following method to your app's root view controller:
- (BOOL)prefersStatusBarHidden
{
return YES;
}
You should add this value to plist: "View controller-based status bar appearance" and set it to "NO".
This will enable you to set the status bar to hidden mode. This sets it to a global unlike other provided answers.
UPDATE: If you want that the status bar would be hidden on splash screen don't forget to mark "Hide during application launch" on target status bar options.
Also, you can add "Status bar is initially hidden" to "YES" on the plist if you don't want to do it with code inside the app.
The code you posted works for iOS 6.1 and below. For iOS 7, Apple has made new methods available to directly control the status bar for each view. Turning off this option in your Info.plist will enable you to hide the status bar, at least for the current Developer Preview (4).
For reference, please take a look at the iOS 7 transition guide that's available on Apple's developer portal.
well I try hide the status bar in all my app and in the "app"-info.plist and I add two rows in the dictionary "Information Property List" I add "View controller-based status bar appearance" set NO and in "Status bar is initially hidden"set YES and for me works n_n'
However, if you use UIImagePicker, the status bar appears again.
In that case, you should hide the status bar as below,
- (void)imagePickerController:(UIImagePickerController *)aPicker didFinishPickingMediaWithInfo:(NSDictionary *)info {
// for iOS7
if ([self respondsToSelector:#selector(setNeedsStatusBarAppearanceUpdate)]) {
[[UIApplication sharedApplication] setStatusBarHidden:YES];
}
After some long searching, I finally found a very simple solution which also takes care of the UIImagePickerController problem.
As mentioned in the other answers, set your status bar hidden in your AppDelegate didFinishLaunching, and set the "View controller-based status bar appearance" to NO.
Then, in your AppDelegate:
- (void)application:(UIApplication *)application didChangeStatusBarFrame:(CGRect)oldStatusBarFrame
{
[application setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
}
et voila - your Status Bar will remain hidden even when the UIImagePickerController is foremost.
This is better than 'rehiding' it every time you present a UIImagePickerController as it remains hidden throughout the app.
To hide the status bar on a particular UIViewController, simply add this:
-(BOOL)prefersStatusBarHidden
{
return YES;
}
Hope this helps !
You can hide from the project summary. there is a checkbox hide during launch.
See the snapshot
I found this solution for me. It works like a charm.
Write this code on your viewcontroller which you wanted to use UIImagePickerController on.
- (void)viewWillDisappear:(BOOL)animated
{
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
}
- (void)viewWillAppear:(BOOL)animated
{
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
}
In addition to the answer from alones above, make sure to implement the imagePickerControllerDidCancel method and add the same code there too.
I was having issues with UIImagePicker as well. Similar to Alones answer, my solution was the following. I added this line or code:
[[UIApplication sharedApplication] setStatusBarHidden:YES];
to this function:
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
I haven't tested this with iOS 6 or older but it works great in iOS 7.
Swift Solution
just add this to your view controllers:
override func prefersStatusBarHidden() -> Bool {
return true
}
I am using Xcode 6, this solution works on iOS 7 and 8 for me:
First, Set the "View controller-based status bar appearance" to NO in plist file.
Second, in AppDelegate, add this:
- (void)application:(UIApplication *)application didChangeStatusBarFrame:(CGRect)oldStatusBarFrame
{
[application setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
}
My problem was that I used view controller containment. Only the top most view controller, which is embedded into a navigation controller for example, can hide or show the status bar.

How do you detect what UIPickerView row has been selected using an if statement

I have made a button so that when it's pressed by the user and a particular row(s) are selected it does something.
So far I have this:
if (pickerView selectedRowInComponent:0) {
[mailComposerTwo setToRecipients:[NSArray arrayWithObjects:#"email#blah.com",nil]];
}
It works on its own. But when I do the if statement multiple times it crashes.
An ways of making it work?
Any help appreciated, thanx.
The problem probably lies with your mail composer, not the picker view. When you show the composer, make sure that you only create it if it hasn't already created.
Also, make sure you release it after you show it:
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
...[configure the picker]
[rootContainer presentModalViewController:picker animated:YES];
[picker release];
NSArray *finalList = [[NSArray alloc]init];
//put all your if statements
if (pickerView selectedRowInComponent:0)
{
[finalList arrayByAddingObjectsFromArray:#[#"email#address.com",#"second#address.com",...];
}
if (pickerView selectedRowInComponent:1)
{
[finalList arrayByAddingObjectsFromArray:#[#"another#address.com",#"fourth#address.com",...];
}
//end of if statements
[mailComposerTwo setToRecipients:finalList];
[self presentViewController:yourInitializedMessageController animated:YES completion:^{NSLog(#"message controller is presented");}];
This will do a single method call rather than continually reassigning which for some odd reason is causing your exception. presentModalViewController:animated: has been deprecated as of iOS 6.0? if not 7.0 I believe.
NOTE! Make the message controller a property of the main view controller. It is good practice so that it is not auto-released by iOS if you need to bring it back up. However if you use MFMessageComposer iOS will keep messenger allocated or running in a thread somewhere so initializing a view controller for it is quick.