Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
A Very Strange Network Problem CDangDrive Mac Basics and Help 2 Oct 7, 2006 10:12 AM
Very strange iTunes Problem - All images in iTMS are broken JasoC0 Mac Applications and Mac App Store 3 Jan 14, 2006 04:48 PM
iChat AV/iSight very strange flickering problem eyeluvmyimac Mac Applications and Mac App Store 0 Dec 25, 2004 11:47 AM
Very, very strange iPod problem w00tmaster Macintosh Computers 9 Jul 24, 2004 01:56 PM
Really Need Help, Very Strange Networking Problem! shadowfax0 Mac Help/Tips 2 Oct 8, 2002 10:15 PM


All times are GMT -5. The time now is 02:46 PM.

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

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