ipad Tabbar Customization Notworking - ipad

I want to Customize the tabbar of iPad. I have attached The image for Clarify my issue.
Currently My Tabbar Like this :
I want Like this.
I have Taken Custom Background Image for tabbar and using the following Code.
-(void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
NSUInteger index=[[tabBarController viewControllers] indexOfObject:viewController];
switch (index)
{
case 0:
[_tabBarController.tabBar setBackgroundImage:[UIImage imageNamed:#"tab_act11.png"]];
break;
case 1:
[_tabBarController.tabBar setBackgroundImage:[UIImage imageNamed:#"tab_act22.png"]];
break;
case 2:
[_tabBarController.tabBar setBackgroundImage:[UIImage imageNamed:#"tab_act33.png"]];
break;
case 3:
[_tabBarController.tabBar setBackgroundImage:[UIImage imageNamed:#"tab_act44.png"]];
break;
case 4:
[_tabBarController.tabBar setBackgroundImage:[UIImage imageNamed:#"tab_act55.png"]];
break;
default:
break;
}
}
From the Above Code it It shows the tabbar as i want But , User interaction not working properly.I m unable to select Propertab.

You need to customize tabBarItem for each view controller not the whole tabBar at once.
For this you can use methods from UITabBarItem header. Following should help you:-
- (void)setFinishedSelectedImage:(UIImage *)selectedImage withFinishedUnselectedImage:(UIImage *)unselectedImage NS_AVAILABLE_IOS(5_0);
You can customize each viewController's tabBarItem using above, before adding them to the tabBarController.

Related

Load every view controllers in tab view

I'm using carbonKit to create a tab view, which contains a dynamic number of tabs. The problem is, each view controller (table views controllers) is loading its content only when I'm going to the tab. I'd like to know if I could load every tabs' content (init and load every view controllers) to navigate flowlessly between each tab.
Here is the code where I init a view controller for a specific tab at index:
- (UIViewController *)tabSwipeNavigation:(CarbonTabSwipeNavigation *)tabSwipe viewControllerAtIndex:(NSUInteger)index {
CommentsTableViewController *tab = [self.storyboard instantiateViewControllerWithIdentifier:#"TabController"];
[tab setPeople:self.peoplepassed];
[tab setQuestion:self.questionpassed];
switch (index) {
case 0:
[tab setTab:#1];
break;
case 1:
[tab setTab:#2];
break;
case 2:
[tab setTab:#3];
break;
case 3:
[tab setTab:#4];
break;
default:
[tab setTab:#1];
break;
}
return tab;
}
Solved by the creator of carbonkit here, should have thought of it earlier, thanks, closed !
EDIT: will mark my own answer as resolved as I have to wait for 2 days

How to change a Button action with Segmented Control

I have a button which has an action that gives a push to another view. My goal is to make this button to open different views according to the selected segment. For example: I have a button called "Request" and have a control segment with two segments, called "Pizza Salt" and "Sweet Pizza." When selected, for example, "Pizza Salt" in the segment and then immediately click the "Request" button, I want to open a view to the menu of "Salt Pizza.", And selected "Sweet Pizza" I want the button to open another view with the menu of the "Sweet Pizza."
Note: I already have the two controllers ready with views.
What code do I use?
My code:
- (IBAction)changeButtonCode:(id)sender {
if (_firstSegmentSixthView.selectedSegmentIndex == 0);
}
- (IBAction)pushToNextView:(id)sender {
}
Use this method to perform actions on different buttons of UIsegmentControl:
- (IBAction) segmentControlBtnAction:(id)sender
{
UISegmentedControl* segmentControl = (UISegmentedControl *)sender;
int index = [segmentControl selectedSegmentIndex];
switch(index)
{
case 0: // Perform action on first button of segment controller
break;
case 1: // Perform action on second button of segment controller
break;
case 2: // Perform action on second button of segment controller
break;
default
break;
}
}
Connect this method with UISegmentControl from xib, using the attribute "value changed".
Upon pressing the request button:
if (_firstSegmentSixthView.selectedSegmentIndex == 0) //salty
{
ViewController1 *vc1 = [[ViewController1 alloc] init];
[self.navigationController pushViewController:vc animated:YES];
}
else if (_firstSegmentSixthView.selectedSegmentIndex == 1) //sweet
{
ViewController2 *vc2 = [[ViewController2 alloc] init];
[self.navigationController pushViewController:vc2 animated:YES];
}

ECSlidingViewController 2 landscape with Right Side Menu have bug

I found the ECSlidingViewController when rotate to landscape, the size of the view is not adjusted. so there is a big blank background shown. it works great in portrait.
this only happen on right side menu.
Please find the screen capture here :
landscape!
portrait!
update on 20-May-2014, sub class the ECSlidingViewController, add these 2 method. but the problem still there.
MyECSlidingViewController.m
-(BOOL)shouldAutorotate
{
return [self.topViewController shouldAutorotate];
}
-(NSUInteger)supportedInterfaceOrientations
{
return [self.topViewController supportedInterfaceOrientations];
}
MenuLeftViewController.m
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *menuItem = self.menuItems[indexPath.row];
self.slidingViewController.topViewController.view.layer.transform = CATransform3DMakeScale(1, 1, 1);
switch (indexPath.row)
{
case 0: // Home
self.slidingViewController.topViewController = [self.storyboard instantiateViewControllerWithIdentifier:#"MainPageNavigationController"];
break;
case 1: // News
self.slidingViewController.topViewController = [self.storyboard instantiateViewControllerWithIdentifier:#"NewsNavigationController"];
break;
case 2: // Songs
self.slidingViewController.topViewController = [self.storyboard instantiateViewControllerWithIdentifier:#"SongsNavigationController"];
break;
case 3: // Notifications
self.slidingViewController.topViewController = [self.storyboard instantiateViewControllerWithIdentifier:#"PushNotificationNavigationController"];
break;
}
[self.slidingViewController resetTopViewAnimated:YES];
}
Try to set shouldAutorotate supportedInterfaceOrientations
If you are trying to set orientation for different pages differently then its a different matter.
To me it seems like this is not possible to EC at the moment. For example the frame of portrait is different that frame of landscape. But when the topviewcontroller is replaced the old frame is just applied to the new topviewcontroller.
This is not a problem when all view controllers supports the same modes. But if some are limited compared to others then entering one of those gives wrong presentation
Hope its fixed in EC 2.0.

Replace navigation bar cancel button with back button

I have a table view controller embedded in a navigation controller. The table cells are all static and selecting any of them will segue to another table view. When segue happened, the navigation bar shows 'Cancel' button for the new view, instead of 'Back' button.
I could add a back button in code like
- (void)viewDidLoad
{
self.navigationItem.backBarButtonItem =
[[UIBarButtonItem alloc] initWithTitle:#"Back"
style:UIBarButtonSystemItemCancel
target:nil
action:nil];
self.navigationItem.leftBarButtonItem = self.navigationItem.backBarButtonItem;
}
But then the back button would be a rectangle shape, not the default back button shape which has an angle on the left edge. How to simply change the cancel button to a system back button?
Here is my code for segue from table cell to the next table view
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
switch (indexPath.row) {
case 0:
[self performSegueWithIdentifier:#"goToSecondTable" sender:self.tableView];
break;
/* and perform segue for other rows */
default:
break;
}
}
And there is nothing to do inside prepareForSegue.
Here is what the connections inspector showed
And Here is the connections for the 'Bar Button Item - Back'
The system provided back button should be the left bar button item by default without having to do anything (in code or in IB).
Remove the connection to the backBarButton in the Connections inspector. Remove the back bar button from the nav bar in IB. Remove the outlet to the back bar button in your code. Run your app, you should see a back bar button provided for you for free.
Why are you performing a segue in didselectrow instead of just pushing the viewcontroller?
try [self.navigationController pushViewController:YOURVIEWCONTROLLER];
that will make sure you have a back button. Also you must use a segue like that, make sure you are using a push segue to your next controller. It also looks like you created your own back button in the second viewController. You do not need to create one, as one will be created for you with the title of the previous viewcontroller. You can make sure it says back by changing self.title = #"Back" in the previous viewcontroller right before you push it.
Codes:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
switch (indexPath.row) {
case 0:
self.title = #"Back";
[self.navigationController pushViewController:SECONDVC];
break;
/* and perform segue for other rows */
default:
break;
}
}
and in viewWillAppear:
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
self.title = #"Whatever you want";
}
Customize the code if don't have default back button not working
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithImage:myBackImage style: UIBarButtonItemStylePlain target:self action:someAction];
self.navigationItem.backBarButtonItem = backButton;
[backButton release];

How do I set action to alert view button (not so simple as that)

I am already trying it through the delegate method clickedButtonAtIndex: but I need to push a view through navigation controller as soon as the user presses "ok"...
I can't allocate the view inside the method, Xcode doesn't recognize the view controller's name in the code. Any idea what I'm coin wrong?
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
switch(buttonIndex) {
case 0:
ReminderCompleted *view = [[ReminderCompleted alloc]initWithNibName:#"ReminderCompleted" bundle:nil];
[view.navigationController pushViewController:view animated:NO];
break;
case 1:
//cancel
break;
default:
break;
}
I get some errors
You cannot push a view, you can only push view controllers. You should be able to structure the code in a similar fashion, but instantiate a view controller (which can also use a nib) instead, and pass that to the navigation controller's push method.
Edit: Your variable name confused me, and you are indeed using a view controller. My suspect now is declaring a new variable inside of a switch, which Objective-C does not like. Try the same code, but declare the variable before the switch (you can leave it uninitialized until the right case happens).
ReminderCompleted *reminderVC;
switch(buttonIndex) {
case 0:
reminderVC = [[ReminderCompleted alloc]initWithNibName:#"ReminderCompleted" bundle:nil];
[view.navigationController pushViewController:view animated:NO];
break;

Resources