Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Aug 9, 2011, 02:39 AM   #1
chen8002004
macrumors newbie
 
Join Date: May 2011
Very strange UIButton problem

I face a very strange UIButton problem. When I press the button and move (do not release), the highlighted area goes to wrong areas (areas that beyond the scope of the view). However, the key inside up event works. Can anyone help?
Declaration:
Code:
@interface datapickerForDayViewController : UIViewController 
{
    UIDatePicker *datePicker;
    UIButton *button;
}
@property ( nonatomic, retain ) IBOutlet UIDatePicker *datePicker;
@property ( nonatomic, retain ) IBOutlet UIButton     *button;;
-(IBAction)buttonPressed: (id)sender;
-(id)initMyFrame:(CGRect)_rect;
@end
Definition:
Code:
@implementation datapickerForDayViewController
@synthesize datePicker;
@synthesize button;
-(id)initMyFrame:(CGRect)_rect
{
    self.view.frame=_rect;
    datePicker = [[UIDatePicker alloc] initWithFrame:CGRectMake(0, 0, _rect.size.width, (_rect.size.height/2))];    
    datePicker.datePickerMode=UIDatePickerModeDate;
    UIButton *myButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    self.button = myButton;
    button.frame = CGRectMake((_rect.size.width/4), (_rect.size.height *2/3), (_rect.size.width/2), (_rect.size.height/6));
    [button setTitle:@"Select Date" forState:UIControlStateNormal];
    [button addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:datePicker];
    [self.view addSubview:button];
    return self;
}
-(IBAction) buttonPressed: (id)sender
{
    ...
}
@end
Use:
Code:
datapickerForDayViewController* myDatePickController=[[datapickerForDayViewController alloc] initWithNibName:nil bundle:nil];
            [myDatePickController initMyFrame:CGRectMake(410, 185, 572, 535)];
            [superview addSubview:myDatePickController.view];
chen8002004 is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Strange problem with 7.1 mohammed-eg iOS 7 4 Mar 19, 2014 04:10 PM
Strange problem srsub3 MacBook Pro 3 Jul 1, 2013 06:32 PM
Strange Problem... please help HyperX13 Mac Pro 0 Nov 30, 2012 03:40 PM
Very Strange Problem kindaobsessed OS X 0 Nov 25, 2012 01:05 AM
2G strange connector problem... rich080487 iPhone Tips, Help and Troubleshooting 0 Jul 17, 2012 02:47 AM

Forum Jump

All times are GMT -5. The time now is 08:49 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC