Dragging a Tab Item
Send Feedback

Glossary Item Box

Topic Overview

Purpose

This topic introduces dragging a tab item to a new position on the IGSlideTabView™ control and uses a code example to demonstrate its usage.

In this topic


Introduction

Dragging a tab summary

Tab items on the IGSlideTabView can be dragged to different positions along the view’s tabLocation side by enabling the isDraggable property found on the IGSlideTabItem instance. This control supports the following isDraggable property enumerations:

  • IGSlideTabDragNever (default) – The tab item is not draggable
  • IGSlideTabDragOpened – The tab item can only be dragged with the tab item expanded
  • IGSlideTabDragClosed – The tab item can only be dragged with the tab item collapsed
  • IGSlideTabDragOpenedOrClosed – The tab item can always be dragged

Dragging a tab item calls two optional delegate methods in the following order.

  1. slideTabView:tabWillDrag:
  2. slideTabView:tabDidDrag:

The optional slideTabView:tabWillDrag: delegate method expects a returned YES or NO to allow or prevent the tab item from being dragged to a new position. Bounds checks are made to close any intersecting expanded tabs when dragging a tab item. The tab item will also stop dragging if the potential drag causes the tabView or contentView to collide with the IGSlideTabView boundaries or another tab item’s tab on a different side of the view.


Dragging a Tab Item – Code Example

Description

The code example below shows how to create and add a tab item to the IGSlideTabView allowing the dragging of tab item; regardless, of the tab being opened or closed.

Prerequisites

This code example requires the inclusion of the IG framework; details about how to add this framework are available in the Adding the IG Framework File topic.

Code

In Objective-C:

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    IGSlideTabView *slideTabView = [[IGSlideTabView alloc] initWithFrame:self.view.bounds];
    slideTabView.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;
    [self.view addSubview:slideTabView];
    IGSlideTabItem *tabItem = [IGSlideTabItem tabWithLocation:IGSlideTabLocationBottom title:@"Example" tabView:nil contentView:nil];
    tabItem.isDraggable = IGSlideTabDragOpenedOrClosed;
    tabItem.contentSize = [IGSlideTabContentSize sizeWithPercentageWidth:0.3 percentageHeight:0.3];
    [slideTabView addTab:tabItem];
}

In C#:

public override void ViewDidLoad ()
{
      base.ViewDidLoad ();
      this.View.BackgroundColor = UIColor.White;
      IGSlideTabView slideTabView = new IGSlideTabView ();
      slideTabView.Frame = this.View.Bounds;
      slideTabView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
      this.View.Add (slideTabView);
      IGSlideTabItem tabItem = new IGSlideTabItem ();
      tabItem.TabLocation = IGSlideTabLocation.IGSlideTabLocationBottom;
      tabItem.Title = "Example";
      tabItem.IsDraggable = IGSlideTabDrag.IGSlideTabDragOpenedOrClosed;
      tabItem.ContentSize = IGSlideTabContentSize.CreatePercentageSize (0.3f, 0.3f);
      slideTabView.AddTab(tabItem);
}

Related Content

Topics

The following topic provides additional information related to this topic.

Topic

Purpose

The topics in this group cover enabling, configuring, and using the IGSlideTabView control’s supported features.