How can I add a TabBar on top of the iPhone? Also I need to set an array of TabBar items dynamically with scroll view.
For more details refer to this url
I need to create tabs like Top News, City, India, World, etc.
UITabBar generally is placed at the bottom of the screen and there usually only one per app. It may be possible to sidestep this, though Apple probably won't like it.
You do not directly manipulate a UITabBar. Instead, you add navigationControllers to the UITabBarController. Tabs can then be manipulated by setting the tabBarItem property on the NavigationController.
All that said having reviewed the screenshot, I am almost certain that a UITabBar is the wrong choice for this. You'd be better off rolling your own control or perhaps using UISegmentedControl.
Related
I am making an app and would like to direct my user once they log in into their dashboard, I have seen some apps display things in what seem like a table view controller or a view controller with a table view. I would like to display the logo up top and then a table displaying their username then about 4 more rows displaying other info then at the bottom a tab bar. What would be the best way to go about this?
any advice welcomed. If relevant I am using swift, Xcode7 and parse to handle my users
Use a UITableView. This a bit more customizable in terms of Storyboard layout. You can place UIImageViews, toolbars, and other elements all over your UIViewController. You can then put a UITableView in the exact place that would work for you, with the dimensions you need.
Of course, you could always use a UITableViewController. You could embed this controller in a variety of combinations, which would let you add tab bars or navigation bars.
The only real difference in implementation is that you have to remember to explicitly write the delegate and data source methods when using a UITableView.
For your case, I would pick whatever seems easiest to implement in your case. Probably a UITableView in my opinion.
Some differences between UITableViewController (TV) and UIViewController with TableView (VT) I know:
You can add other controls into VT and pin it to anywhere you want. TV can't do that.
You can add many same group of controls without add constraints with TV. VT you have to add constraints.
You don't want to worry about scrolling in TV with many group of controls.
With TV you can create static table cell but you can't with VT. Static table works on TableViewController only.
In your situation, I use UITableViewController with static table to achieve that.
Hope this can help.
I am developing app that has multiple skins and I have a dilemma on how to implement this.
One of the solutions would be to have separate nib files for every skin, and load it depending on which skin is currently selected. Problem with this is that I can't edit navigation bar of navigation controller (which my app uses), and I have to change it's background image and back button image etc.. I came up with an idea to hide this navigation bar on every screen and replace it with custom UIView in Interface Builder which will act as navigation bar and custom back button with IBAction for popping current View Controller, so that user won't see any difference.
Is this approach acceptable and if I make it this way, will I have problems with rejection in App Store?
If you choose to hide & replace the UINavigationBar with your own UIView it's no problem as far as Apple goes.
However, I can tell you that you will have to spend some time trying to replicate some visual effects that come naturally with UINavigationBar.
For example, when you push/pop a new controller, you will see that the navigation bar title will slide & fade beautifully. The same applies for left and right bar items.
Personally I would not completely hide the UINavigationBar, but customize it. In the end it all depends on what you want, but by default the UINavigationBar is pretty customizable.
You can add your own buttons or even entire UIViews as left and right bar items. Also, you can add your own UIView as the title (with your own label, custom font or whatever) or change the background.
EDIT:
To easily customize the looks in your entire application, you can subclass UINavigationController and create your own CustomUINavigationController. Then, in viewDidLoad method you can change whatever you want to the navigation bar and this will be accessible in the entire application.
No way, what you are doing is perfect. This will work & no way it will get rejected from app store (just based on this approach). I too have explored several ways to provide skins & what you wrote seemed to be the least hassle-some. Plus its way more easier to create UI elements in Interface Builder hence the separate nib files for different skins.
I am saying this so confidently 'coz I have done the same thing & app store approved.
Best of luck.
The UITabBar in my app consists of 10+ items, but the width is enough to put all 10+ items.
How to make a horizontal scrollable UITabBar in iOS ?
Thanks.
You'll have to roll your own to at least some extent.
What might work, would be to create a UITabBar view (not the controller) and embedded it in a UIScrollView. You could then use that in place of your regular Tab Bar control by adding it to your TabBarController.view/tabBarView or something. Of course you'd have to play around to get it to look right, and I'm not sure if just setting the view to something wider will actually make it display more items or not.
Of course, for best results you'd probably want to do something entirely custom.
From Apple's Developer Portal:
If you add more than five items to the viewControllers property, the tab bar controller automatically inserts a special view controller (called the More view controller) to handle the display of the additional items.
Source
Seems like you will need to make a custom tab bar.
They also said this in the next paragraph:
Although the tab bar view is a key part of your tab bar interface, you do not modify that view directly.
You might be breaking Apple's design guidelines by doing this.
You can certainly go and create a custom class of the UITabBar (embedding it into a scrollview etc.)..but why re-invent the wheel? After searching around I found several third-party classes already created that work well and are easy to use and highly customizable..In order of personal preference:
M13InfiniteTabBar -
https://github.com/Marxon13/M13InfiniteTabBar
JSScrollableTabBar -
https://github.com/jasarien/JSScrollableTabBar
InfiniTabBar -
https://github.com/iosdeveloper/InfiniTabBar
I have a UITableView which is long and scrollable, also I use UINAvigationController. At the bottom of the page in the footer I plan to put a next button which will help to go next page.
The problem is "sometimes" this page may need to show some messages in html, so I must use uiwebview preferebaly at the bottom of the page just above the footer, it shouldnt get effected from scrolling.
-Can I use uitableview and uiwebview on same page? the page is already in control of a uitableview controller, so how will i control or put delegates of a uiwebview?
-Can I make this uiwebview invisible and not allocate space when there are no messages to be shown?
Yes, it's possible.
I believe the Stocks app for the iPhone utilizes multiple views with their own controllers. I think a better solution would be is to have a UIPageControl and create a UITableViewController when the UIPageControl's value changed.
If you still want to create UINavigationController, just set its rootViewController to a UITableViewController and set its toolbarHidden property to NO, the toolbar has the behavior you want, it stays fixed on the bottom of the screen, if that's what you meant. Then add the navigational buttons.
As for UIWebView's, just dynamically create it once you get an error and set its hidden property to YES. You wouldn't want to be destroying and recreating UIWebViews every time you get an error as that can be very expensive. Just create once and hide it.
I am trying to build a screen like this:
I've already built the navigationItem (the "title Bar") and the table view, now I'm looking for a way to add the buttons under the table view.
The result should look similar to a tab bar, but as the buttons are used to influence the the number of displayed records in the table, I'm only dealing with one controller.
How do I achieve what I'm looking for?
I can think of two ways off the top of my head you could accomplish something like this.
You could create a UISegmentedControl and place it in your tableview's tableFooterView property. The buttons would only be visible underneath the tableview and would scroll with the table.
You could create a UIToolbar, or ideally display the toolbar you get for free with the navigation controller, and place a UISegmentedControl there. This way the buttons would always be visible regardless of where the user has scrolled to.
Hope this gets you started.
A couple of approaches suggest themselves:
1) You could use an actual tab bar. If you do that, your outermost view controller has to be the UITabBarController. Some searching on "UITableView inside UITabBar" and the like should give you more details.
2) Set the frame of the UITableView to be less than the whole screen. Have both it and the buttons (which might well be a UISegmentedControl) be subviews of a common container.