Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9009437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:11:46+00:00 2026-06-16T02:11:46+00:00

I am building a custom slider to my application. I found a library on

  • 0

I am building a custom slider to my application.

I found a library on Github as inspiration.

I have created the file: NKSlider as a subclass of UIView and implemented on it the drawRect as the library did and implemented the methods: touchesMoved:withEvent: and touchesBegan:withEvent:. But none of the touches events are being called.

this is how i add this custom view to my view controller:

NKHandler *nk = [[NKHandler alloc] init];
nk.frame = CGRectMake(20, 20, 280, 36);
[self.view addSubview:nk];
[self.view addSubview:[[NKHandler alloc] initWithFrame:CGRectMake(20, 60, 280, 100)]];

and this are the classes. What am i doing wrong??

the .h

#import <UIKit/UIKit.h>

@interface NKHandler : UIView

@end

and .m

#import "NKHandler.h"

static inline CGPoint CGPointTopCenter(CGRect rect) {
  CGPoint p; p.x = rect.origin.x + (rect.size.width / 2); p.y = rect.origin.y; return p;
}
static inline CGPoint CGPointBottomCenter(CGRect rect) {
  CGPoint p; p.x = rect.origin.x + (rect.size.width / 2); p.y = rect.origin.y + rect.size.height; return p;
}
static inline CGPoint CGPointLeftCenter(CGRect rect) {
  CGPoint p; p.x = rect.origin.x; p.y = rect.origin.y + (rect.size.height / 2); return p;
}
static inline CGPoint CGPointRightCenter(CGRect rect) {
  CGPoint p; p.x = rect.origin.x + rect.size.width; p.y = rect.origin.y + (rect.size.height / 2); return p;
}

@implementation NKHandler {
  int _selectedStep;
}

-(id)init {
  self = [super init];
  if (self) {
    self.backgroundColor = [UIColor clearColor];

    self.clipsToBounds = NO;
    self.opaque = YES;

    _selectedStep = 5;   
  }
  return self;
}

-(void) setStep:(int) step {
  _selectedStep = step;
  [self setNeedsDisplay];
}

-(void)layoutSubviews {
  ... layout stuff ...
}
-(void)drawRect:(CGRect)rect {
  ... Boring drawing stuff ..
}

#pragma mark - Touch Handling

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
  NSLog(@"%s", __PRETTY_FUNCTION__);
  [self setStep:(_selectedStep+1)%11];
}

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
  NSLog(@"%s", __PRETTY_FUNCTION__);
}

@end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T02:11:48+00:00Added an answer on June 16, 2026 at 2:11 am
    nk.userInteractionEnabled = YES;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Iam building a custom rating bar. With help of kozyr's article i have created
Im building a custom UIView similar to UIPopover view , simply I subclass the
I am building a custom field feature for my application. This allows the administrator
I'm building a custom Ubuntu kernel and have modified one of the source files.
I'm building a custom WordPress theme and have a quick question regarding WordPress and
I'm building a custom UIView, which draws its own content in a drawRect: Method.
I have problems displaying error_messages.html.erb partial when building custom validation. I have for instance,
Have a project where were building custom business reports accessible via web browser. As
I am building a custom, in-application settings view based on UITableViewCellStyle1 (or so). I
I am building a custom module in Drupal 7. I have a URL which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.