HMSegmentedControl: scroll only in one direction (DOWN/UP or Right/Left) XCODE

I used this one for my segment control: https://github.com/HeshamMegid/HMSegmentedControl

The Content and Design is ok, the segment control is working. But if I scroll, at the scrollview, you can scroll Right/Left and Up/Down simultaneously. Is it possible, to scroll only in one direction? Only Up/Down Or only Right/Left?

Code:

// Tying up the segmented control to a scroll view self.segmentedControl4 = [[HMSegmentedControl alloc] initWithFrame:CGRectMake(0, 0, viewWidth, 50)]; self.segmentedControl4.sectionTitles = @[@"Automotive", @"Baustoffe", @"Chemie", @"Lebensmittel", @"Maschinenbau", @"Papier"]; self.segmentedControl4.selectedSegmentIndex = 0; self.segmentedControl4.backgroundColor = [UIColor colorWithRed:100.0/255.0 green:100.0/255.0 blue:100.0/255.0 alpha:1]; self.segmentedControl4.titleTextAttributes = @{NSForegroundColorAttributeName : [UIColor whiteColor]}; self.segmentedControl4.selectedTitleTextAttributes = @{NSForegroundColorAttributeName : [UIColor whiteColor]}; self.segmentedControl4.selectionIndicatorHeight = 8.0f; self.segmentedControl4.selectionIndicatorColor = [UIColor colorWithRed:150.0/255.0 green:150.0/255.0 blue:150.0/255.0 alpha:1];; self.segmentedControl4.selectionStyle = HMSegmentedControlSelectionStyleFullWidthStripe; self.segmentedControl4.selectionIndicatorLocation = HMSegmentedControlSelectionIndicatorLocationDown; self.segmentedControl4.segmentWidthStyle = HMSegmentedControlSegmentWidthStyleDynamic; self.segmentedControl4.segmentEdgeInset = UIEdgeInsetsMake(0, 5, 0, 5); self.segmentedControl4.tag = 0; // Test self.segmentedControl4.shouldAnimateUserSelection = NO; [self.segmentedControl4 addTarget:self action:@selector(segmentedControlChangedValue:) forControlEvents:UIControlEventValueChanged]; __weak typeof(self) weakSelf = self; [self.segmentedControl4 setIndexChangeBlock:^(NSInteger index) { [weakSelf.scrollView scrollRectToVisible:CGRectMake(viewWidth * index, 0, viewWidth, 200) animated:YES]; }]; [self.view addSubview:self.segmentedControl4]; self.scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 50, viewWidth, viewHeight)]; self.scrollView.backgroundColor = [UIColor whiteColor]; self.scrollView.pagingEnabled = YES; self.scrollView.showsHorizontalScrollIndicator = NO; //self.scrollView.contentSize = CGSizeMake(viewWidth * 6, scrollViewHeight-50); self.scrollView.delegate = self; self.scrollView.tag = 1234567; self.automaticallyAdjustsScrollViewInsets = NO; [self.scrollView scrollRectToVisible:CGRectMake(0, 0, viewWidth, 200) animated:NO]; [self.view addSubview:self.scrollView];// Seite 1 - Automotive UIImageView *image1 =[[UIImageView alloc] initWithFrame:CGRectMake(0,0,viewWidth,200)]; image1.image=[UIImage imageNamed:@"automotive.png"]; [self.scrollView addSubview:image1]; UIImageView *logo1 =[[UIImageView alloc] initWithFrame:CGRectMake(20,220,50,50)]; logo1.image=[UIImage imageNamed:@"logo_automotive.png"]; [self.scrollView addSubview:logo1]; int textPositionTop = image1.frame.size.height + logo1.frame.size.height + 30; NSString *sTitel1 = @"Test"; NSString *sText1 = @"Test Text"; CGSize titelLabelSize1 = [sTitel1 sizeWithFont:[UIFont boldSystemFontOfSize:30] constrainedToSize:CGSizeMake(viewWidth, MAXFLOAT) lineBreakMode:NSLineBreakByWordWrapping]; UILabel *label1 = [[UILabel alloc] initWithFrame:CGRectMake(90,textPositionTop-logo1.frame.size.height,viewWidth-60-50,titelLabelSize1.height)]; label1.numberOfLines = 0; label1.text = sTitel1; [self.scrollView addSubview:label1]; textPositionTop += label1.frame.size.height; CGFloat scrollViewHeight = image1.frame.size.height + logo1.frame.size.height + text1.frame.size.height + (3*20)+160; [self.scrollView setContentSize:CGSizeMake(viewWidth*6, scrollViewHeight-50)];

}

Category:ios Views:2 Time:2019-01-30
Tags: xcode ios apple

Related post

  • .contents of p element. Only goes one level down-need all contents. jquery 2011-06-21

    Have a problem. Taking this html: <p><span>js fiddle is a playground for web developers, a tool which may be used in many ways. One can use it as an online editor for snippets build from HTML, CSS and JavaScript. The code can then be shar

  • Scroll wheel only scrolling/zooming in one direction in some programs 2014-02-05

    When I use a scroll-wheel (either an external or optical mouse or the laptop touchpad scroll-wheel) on my laptop (with Windows Vista), it only scrolls or zooms in one direction in some programs. For example, when I scroll in either direction in Googl

  • UIScrollView disable scrolling in just one direction? 2011-03-20

    I've been unable to find an answer for this (maybe someone has hacked a solution together). Is it possible to disable scrolling in a UIScrollView in one direction? I am not talking about disabling vertical or horizontal scrolling, but one direction o

  • HTML5 Touchmove event only in one direction 2012-02-10

    Im creating an object to drag with "touchmove" in Y but i want it only to be dragged in one direction, up! But it also makes it go down.. How can i solve this? In each interval of Y some actions will take place there and the objective is to drag the

  • Enable scrolling only for one section in UITableView 2011-05-05

    I have a two sections in my table view. First contains two rows, and second much more. I need scrolling only for second section. Is it possible? --------------Solutions------------- No. A table view is just one big thing. If you want to have the firs

  • WP7 - ItemsControl (or ListBox) scroll only by one item 2012-01-08

    Simple question... Is it possible to scroll ItemsControl always only by one item? edited Ok i added dependency property for VerticalOffest of ScrollView var _listScrollViewer = elements.Where(x => x is ScrollViewer).FirstOrDefault() as ScrollViewe

  • Calendar sync only working one direction 2014-08-16

    I am having a calendar sync issue. Appointments on my Outlook calendar are making it on to my PDA, my appointments on my PDA are not getting on my Outlook calendar. Active sync is showing a sucessful sync. Any thoghts? --------------Solutions--------

  • Get Acceleration only in one direction using ACCELEROMETER 2011-03-03

    I am using SensorEventListener for geting gravity.. But I want Gravity only x-direction.. What I do for geting acceleration value only in X-direction.. --------------Solutions------------- To be more specific from the answer from Rajnikant, look here

  • Microsoft Wireless Mouse 5000 scrolling error only in one direction 2013-01-16

    I have a Microsoft Wireless Desktop 3000 keyboard and mouse set. The mouse is Microsoft Wireless Mouse 5000. Keyboard is working perfectly. There is a problem only with the mouse up scrolling (by the wheel). It's scroll just a bit or nothing. Down sc

  • Homegroup works only in one direction. 2012-12-01

    I have a laptop just upgraded to Win 7 Pro. It needs to share printers connected locally to desktop running Win 7 Home Premium. The laptop was able to join the Homegroup only after deleting and recreating it on the desktop. Now desktop can see laptop

  • If ScrollView only supports one direct child, how am I supposed to make a whole layout scrollable? 2010-11-23

    I have 3 text views in a layout, where the text clips a tad on the bottom on my droid 2...hhow can I ensure that the whole text is viewable and the user can scroll down (simply with their finger) to see the rest of my text? Thanks! EDIT: <?xml ver

  • IOS: drag uiimageview only in one direction 2012-03-01

    I want to drag an uiimageview only in horizontal from a point1 to a point2; how can I do it? --------------Solutions------------- you can use somting like this: - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { touchStart = [[touches

  • My outlook calendar only syncs one direction 2014-06-24

    My outlook will send out to my HTC trophy phone and windows live but will not receive anything from either. I don't use outlook for email so that can't be an issue. I get the sync error There was an error synchronizing your folder hierarchy. Error :

  • OneNote MX synchronizing only in one direction 2013-12-30

    I have OFFICE 2013 on desktop computer, OFFICE 2013 and OneNote MX on Tablet. On all I have the same notebook. When I write something on computer I see changes on tablet OneNote and MX. When I changed something in MX I don't see any changes on deskto

  • A fetch request can only fetch one entity at a time, right? 2010-06-08

    Is that true? Or could I fetch multiple entities at once? If so, how would that look like? (Guess: No. NSFetchRequest asks for one and only one entity) --------------Solutions------------- NSFetchRequest *request = [[NSFetchRequest alloc] init]; NSEn

  • popup in Chrome browser action only if click on down arrow on right side of the icon 2011-11-27

    I am developing a Chrome extension with browser action. I want to make some action on clicking on browser action icon (it is easy, not a problem), and show popup if user clicks on down arrow at the right side of the icon (that is a problem). So, we w

  • Mouse will only scroll in one direction (if at all) 2013-10-04

    Hi there, I have a particularly weird mouse issue on our work PC; mouse scrolling refuses to work in most applications (Chrome, Word, etc.). Yet in a handful of applications (IE and AutoCAD) scrolling works, but only in one direction. For example in

  • How can I avoid "IllegalStateException: Scrollview can host only one direct child"? 2010-09-17

    I am using ScrollView in my Android Layout but it shows IllegalStateException "Scrollview can host only one direct child" How can I avoid this exception? --------------Solutions------------- You have added more than one controls as children of a Scro

  • My new Epson Stylus SX515W printer will only communicate in one direction with my new Windows 7 computer. 2014-12-12

    Although the printer sucessfully installed and is recognised by the computer, it will not print from the computer,all I get is an error message with yellow warning triangle,stating printing blocked by previos requested print. I then remove that from

  • Moving a cocos2d-iphone+box2d boy in one direction 2011-07-20

    Please can someone advice me on this. I have a cocos2d-iphone +box2d body I wish to move only in one direction(movement only from left to right of the iphone screen) using only the accelerometer controls and parallax scrolling. Please how do I do thi

  • uiscrollview scrolls only downward 2011-08-03

    I'm implementing a custom UIView with nested UIScrollView. initialization looks like: - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(10, 10, 252, 200)];

  • What do I do if I have a ViewFlipper and ScrollView only wraps one child? 2010-11-23

    I really only need my scrollview wrapped around 1 of the 3 linear layouts I have in my view flipper, but I try to wrap it around my 3rd child and it gives me the error that ScrollView can only host one direct child. Any workarounds? <ViewFlipper

  • Is it possible to remove the minimize button down in the right corner in windows 7? 2012-09-13

    Is it possible to remove the minimize button down in the right corner in windows 7? --------------Solutions------------- Hi, There are certain non-Microsoft applications available to hide Show Desktop button. You may use your favorite search engine t

  • My new Microsoft Wireless Mouse 5000 will only scroll in one direction in Quicken. That seems to be the only program with problems. Any answers? 2013-12-10

    My new Microsoft Wireless Mouse 5000 will only scroll in one direction in Quicken. That seems to be the only program with problems. Any answers? --------------Solutions------------- Hi retiredinflorida, Welcome to Microsoft Vista answers Forum! This

  • UIPickerView with Date only rotating in one direction 2010-10-14

    I am experiencing a strange behavior with a UIPickerView: I am trying to show an Date Picker within an action sheet. Everything works well, except that the wheels are only rotating in one direction at first! If you start rotating up and change the di

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.094 (s). 11 q(s)