Search Results

Search found 447 results on 18 pages for 'uibutton'.

Page 11/18 | < Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >

  • iphone twitter posting

    - by user313100
    I have some twitter code I modified from: http://amanpages.com/sample-iphone-example-project/twitteragent-tutorial-tweet-from-iphone-app-in-one-line-code-with-auto-tinyurl/ His code used view alerts to login and post to twitter but I wanted to change mine to use windows. It is mostly working and I can login and post to Twitter. However, when I try to post a second time, the program crashes with a: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[NSCFString text]: unrecognized selector sent to instance 0xc2d560' I'm a bit of a coding newbie so any help would be appreciated. If I need to post more code, ask. #import "TwitterController.h" #import "xmacros.h" #define XAGENTS_TWITTER_CONFIG_FILE DOC_PATH(@"xagents_twitter_conifg_file.plist") static TwitterController* agent; @implementation TwitterController BOOL isLoggedIn; @synthesize parentsv, sharedLink; -(id)init { self = [super init]; maxCharLength = 140; parentsv = nil; isLogged = NO; isLoggedIn = NO; txtMessage = [[UITextView alloc] initWithFrame:CGRectMake(30, 225, 250, 60)]; UIImageView* bg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"fb_message_bg.png"]]; bg.frame = txtMessage.frame; lblCharLeft = [[UILabel alloc] initWithFrame:CGRectMake(15, 142, 250, 20)]; lblCharLeft.font = [UIFont systemFontOfSize:10.0f]; lblCharLeft.textAlignment = UITextAlignmentRight; lblCharLeft.textColor = [UIColor whiteColor]; lblCharLeft.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0]; txtUsername = [[UITextField alloc]initWithFrame:CGRectMake(125, 190, 150, 30)]; txtPassword = [[UITextField alloc]initWithFrame:CGRectMake(125, 225, 150, 30)]; txtPassword.secureTextEntry = YES; lblId = [[UILabel alloc]initWithFrame:CGRectMake(15, 190, 100, 30)]; lblPassword = [[UILabel alloc]initWithFrame:CGRectMake(15, 225, 100, 30)]; lblTitle = [[UILabel alloc]initWithFrame:CGRectMake(80, 170, 190, 30)]; lblId.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0]; lblPassword.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0]; lblTitle.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0]; lblId.textColor = [UIColor whiteColor]; lblPassword.textColor = [UIColor whiteColor]; lblTitle.textColor = [UIColor whiteColor]; txtMessage.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0]; lblId.text = @"Username:"; lblPassword.text =@"Password:"; lblTitle.text = @"Tweet This Message"; lblId.textAlignment = UITextAlignmentRight; lblPassword.textAlignment = UITextAlignmentRight; lblTitle.textAlignment = UITextAlignmentCenter; txtUsername.borderStyle = UITextBorderStyleRoundedRect; txtPassword.borderStyle = UITextBorderStyleRoundedRect; txtMessage.delegate = self; txtUsername.delegate = self; txtPassword.delegate = self; login = [[UIButton alloc] init]; login = [UIButton buttonWithType:UIButtonTypeRoundedRect]; login.frame = CGRectMake(165, 300, 100, 30); [login setTitle:@"Login" forState:UIControlStateNormal]; [login addTarget:self action:@selector(onLogin) forControlEvents:UIControlEventTouchUpInside]; cancel = [[UIButton alloc] init]; cancel = [UIButton buttonWithType:UIButtonTypeRoundedRect]; cancel.frame = CGRectMake(45, 300, 100, 30); [cancel setTitle:@"Back" forState:UIControlStateNormal]; [cancel addTarget:self action:@selector(onCancel) forControlEvents:UIControlEventTouchUpInside]; post = [[UIButton alloc] init]; post = [UIButton buttonWithType:UIButtonTypeRoundedRect]; post.frame = CGRectMake(165, 300, 100, 30); [post setTitle:@"Post" forState:UIControlStateNormal]; [post addTarget:self action:@selector(onPost) forControlEvents:UIControlEventTouchUpInside]; back = [[UIButton alloc] init]; back = [UIButton buttonWithType:UIButtonTypeRoundedRect]; back.frame = CGRectMake(45, 300, 100, 30); [back setTitle:@"Back" forState:UIControlStateNormal]; [back addTarget:self action:@selector(onCancel) forControlEvents:UIControlEventTouchUpInside]; loading1 = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; loading1.frame = CGRectMake(140, 375, 40, 40); loading1.hidesWhenStopped = YES; [loading1 stopAnimating]; loading2 = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; loading2.frame = CGRectMake(140, 375, 40, 40); loading2.hidesWhenStopped = YES; [loading2 stopAnimating]; twitterWindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; [twitterWindow addSubview:txtUsername]; [twitterWindow addSubview:txtPassword]; [twitterWindow addSubview:lblId]; [twitterWindow addSubview:lblPassword]; [twitterWindow addSubview:login]; [twitterWindow addSubview:cancel]; [twitterWindow addSubview:loading1]; UIImageView* logo = [[UIImageView alloc] initWithFrame:CGRectMake(35, 165, 48, 48)]; logo.image = [UIImage imageNamed:@"Twitter_logo.png"]; [twitterWindow addSubview:logo]; [logo release]; twitterWindow2 = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; [twitterWindow2 addSubview:lblTitle]; [twitterWindow2 addSubview:lblCharLeft]; [twitterWindow2 addSubview:bg]; [twitterWindow2 addSubview:txtMessage]; [twitterWindow2 addSubview:lblURL]; [twitterWindow2 addSubview:post]; [twitterWindow2 addSubview:back]; [twitterWindow2 addSubview:loading2]; [twitterWindow2 bringSubviewToFront:txtMessage]; UIImageView* logo1 = [[UIImageView alloc] initWithFrame:CGRectMake(35, 155, 42, 42)]; logo1.image = [UIImage imageNamed:@"twitter-logo-twit.png"]; [twitterWindow2 addSubview:logo1]; [logo1 release]; twitterWindow.hidden = YES; twitterWindow2.hidden = YES; return self; } -(void) onStart { [[UIApplication sharedApplication]setStatusBarOrientation:UIInterfaceOrientationPortrait]; twitterWindow.hidden = NO; [twitterWindow makeKeyWindow]; [self refresh]; if(isLogged) { twitterWindow.hidden = YES; twitterWindow2.hidden = NO; [twitterWindow2 makeKeyWindow]; } } - (void)textFieldDidBeginEditing:(UITextField *)textField { [textField becomeFirstResponder]; } - (BOOL)textFieldShouldReturn:(UITextField *)textField { [textField resignFirstResponder]; return NO; } - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{ const char* str = [text UTF8String]; int s = str[0]; if(s!=0) if((range.location + range.length) > maxCharLength){ return NO; }else{ int left = 139 - ([sharedLink length] + [textView.text length]); lblCharLeft.text= [NSString stringWithFormat:@"%d",left]; // this fix was done by Jackie //http://amanpages.com/sample-iphone-example-project/twitteragent-tutorial-tweet-from-iphone-app-in-one-line-code-with-auto-tinyurl/#comment-38026299 if([text isEqualToString:@"\n"]){ [textView resignFirstResponder]; return FALSE; }else{ return YES; } } int left = 139 - ([sharedLink length] + [textView.text length]); lblCharLeft.text= [NSString stringWithFormat:@"%d",left]; return YES; } -(void) onLogin { [loading1 startAnimating]; NSString *postURL = @"http://twitter.com/statuses/update.xml"; NSString *myRequestString = [NSString stringWithFormat:@""]; NSData *myRequestData = [ NSData dataWithBytes: [ myRequestString UTF8String ] length: [ myRequestString length ] ]; NSMutableURLRequest *request = [ [ NSMutableURLRequest alloc ] initWithURL: [ NSURL URLWithString:postURL ] ]; [ request setHTTPMethod: @"POST" ]; [ request setHTTPBody: myRequestData ]; NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:request delegate:self]; if (!theConnection) { UIAlertView* aler = [[UIAlertView alloc] initWithTitle:@"Network Error" message:@"Failed to Connect to twitter" delegate:nil cancelButtonTitle:@"Close" otherButtonTitles:nil]; [aler show]; [aler release]; } [request release]; } -(void) onCancel { [[NSUserDefaults standardUserDefaults] setValue:@"NotActive" forKey:@"Twitter"]; twitterWindow.hidden = YES; [[UIApplication sharedApplication]setStatusBarOrientation:UIInterfaceOrientationLandscapeRight]; } -(void) onPost { [loading2 startAnimating]; NSString *postURL = @"http://twitter.com/statuses/update.xml"; NSString *myRequestString; if(sharedLink){ myRequestString = [NSString stringWithFormat:@"&status=%@",[NSString stringWithFormat:@"%@\n%@",txtMessage.text,sharedLink]]; }else{ myRequestString = [NSString stringWithFormat:@"&status=%@",[NSString stringWithFormat:@"%@",txtMessage.text]]; } NSData *myRequestData = [ NSData dataWithBytes: [ myRequestString UTF8String ] length: [ myRequestString length ] ]; NSMutableURLRequest *request = [ [ NSMutableURLRequest alloc ] initWithURL: [ NSURL URLWithString:postURL ] ]; [ request setHTTPMethod: @"POST" ]; [ request setHTTPBody: myRequestData ]; NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:request delegate:self]; if (!theConnection) { UIAlertView* aler = [[UIAlertView alloc] initWithTitle:@"Network Error" message:@"Failed to Connect to twitter" delegate:nil cancelButtonTitle:@"Close" otherButtonTitles:nil]; [aler show]; [aler release]; } [request release]; } - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { // release the connection, and the data object [connection release]; if(isAuthFailed){ UIAlertView* aler = [[UIAlertView alloc] initWithTitle:@"Login Failed" message:@"Invalid ID/Password" delegate:nil cancelButtonTitle:@"Close" otherButtonTitles:nil]; [aler show]; [aler release]; }else{ UIAlertView* aler = [[UIAlertView alloc] initWithTitle:@"Connection Failed" message:@"Failed to connect to Twitter" delegate:nil cancelButtonTitle:@"Close" otherButtonTitles:nil]; [aler show]; [aler release]; } isAuthFailed = NO; } - (void)connectionDidFinishLoading:(NSURLConnection *)connection { isAuthFailed = NO; [loading1 stopAnimating]; [loading2 stopAnimating]; if(isLogged) { UIAlertView* aler = [[UIAlertView alloc] initWithTitle:@"Twitter" message:@"Tweet Posted!" delegate:nil cancelButtonTitle:@"Close" otherButtonTitles:nil]; [aler show]; [aler release]; txtMessage = @""; [self refresh]; } else { twitterWindow.hidden = YES; twitterWindow2.hidden = NO; [[NSNotificationCenter defaultCenter] postNotificationName:@"notifyTwitterLoggedIn" object:nil userInfo:nil]; } isLogged = YES; isLoggedIn = YES; } -(void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge { NSDictionary* config = [NSDictionary dictionaryWithObjectsAndKeys:txtUsername.text,@"username",txtPassword.text,@"password",nil]; [config writeToFile:XAGENTS_TWITTER_CONFIG_FILE atomically:YES]; if ([challenge previousFailureCount] == 0) { NSURLCredential *newCredential; newCredential=[NSURLCredential credentialWithUser:txtUsername.text password:txtPassword.text persistence:NSURLCredentialPersistenceNone]; [[challenge sender] useCredential:newCredential forAuthenticationChallenge:challenge]; } else { isAuthFailed = YES; [[challenge sender] cancelAuthenticationChallenge:challenge]; } } -(void) refresh { NSDictionary* config = [NSDictionary dictionaryWithContentsOfFile:XAGENTS_TWITTER_CONFIG_FILE]; if(config){ NSString* uname = [config valueForKey:@"username"]; if(uname){ txtUsername.text = uname; } NSString* pw = [config valueForKey:@"password"]; if(pw){ txtPassword.text = pw; } } } + (TwitterController*)defaultAgent{ if(!agent){ agent = [TwitterController new]; } return agent; } -(void)dealloc { [super dealloc]; [txtMessage release]; [txtUsername release]; [txtPassword release]; [lblId release]; [lblPassword release]; [lblURL release]; [twitterWindow2 release]; [twitterWindow release]; } @end

    Read the article

  • How to call PopOver Controller from UITableViewCell.accessoryView?

    - by Vic
    Hi, First I would like to say that I'm really new to ipad/ipod/iphone development, and to objective-c too. With that being said, I'm trying to develop a small application targeting the iPad, using Xcode and IB, basically, I have a table, for each UITableViewCell in the table, I added to the accessoryView a button that contains an image. Here is the code: UIImage *img = [UIImage imageNamed:@"myimage.png"]; UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; CGRect frame = CGRectMake(0.0, 0.0, img.size.width, img.size.height); button.frame = frame; // match the button's size with the image size [button setBackgroundImage:img forState:UIControlStateNormal]; // set the button's target to this table view controller so we can interpret touch events and map that to a NSIndexSet [button addTarget:self action:@selector(checkButtonTapped:event:) forControlEvents:UIControlEventTouchUpInside]; button.backgroundColor = [UIColor clearColor]; cell.accessoryView = button; So far, so good, now the problem is that I want a PopOver control to appear when a user taps the button on the accessoryView of a cell. I tried this on the "accessoryButtonTappedForRowWithIndexPath" of the tableView: UITableViewCell *cell = [myTable cellForRowAtIndexPath:indexPath]; UIButton *button = (UIButton *)cell.accessoryView; //customViewController is the controller of the view that I want to be displayed by the PopOver controller customViewController = [[CustomViewController alloc]init]; popOverController = [[UIPopoverController alloc] initWithContentViewController: customViewController]; popOverController.popoverContentSize = CGSizeMake(147, 122); CGRect rect = button.frame; [popOverController presentPopoverFromRect:rect inView:cell.accessoryView permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES]; The problem with this code is that it shows the Popover at the top of the application View, while debugging I saw the values of "rect" and they are: x = 267 y = 13 so I think it is pretty obvious why the PopOver is being displayed so up on the view, so my question is, how can I get the correct values for the PopOver to appear just below the button on the accessoryView of the cell? Also, as you can see, I'm telling it to use the "cell.accessoryView" for the "inView:" attribute, is that okay?

    Read the article

  • error: expected specifier-qualifier-list before...in Objective C ?

    - by Ridwan
    Hi guys. Whenever I build the following code, I get the error above. //Controller.h #import <UIKit/UIKit.h> #import <Foundation/Foundation.h> #import "PolygonShape.h" #import "PolygonView.h"; @interface Controller : NSObject { IBOutlet UIButton *decreaseButton; IBOutlet UIButton *increaseButton; IBOutlet UILabel *numberOfSidesLabel; IBOutlet PolygonShape *shape; IBOutlet PolygonView *shapeView; } - (IBAction)decrease; - (IBAction)increase; - (void)awakeFromNib; @end //Controller.m #import "Controller.h" @implementation Controller @end However, when I replace the import statement and put a forward class reference instead, the code compiles. //Controller.h #import <UIKit/UIKit.h> #import <Foundation/Foundation.h> #import "PolygonShape.h" @class PolygonView; @interface Controller : NSObject { IBOutlet UIButton *decreaseButton; IBOutlet UIButton *increaseButton; IBOutlet UILabel *numberOfSidesLabel; IBOutlet PolygonShape *shape; IBOutlet PolygonView *shapeView; } - (IBAction)decrease; - (IBAction)increase; - (void)awakeFromNib; @end //Controller.m #import "Controller.h" #import "PolygonView.h" @implementation Controller @end Can anyone explain?

    Read the article

  • Pin animatesDrop mapView-iOS

    - by user1724168
    I have implemented code as seen below. I would like to add animation with dropping effect. However, once I type pinView.animatesDrop does not recognize! I could not able to figure out what I am doing wrong? - (MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation:(id <MKAnnotation>)annotation { MKAnnotationView *pinView=nil; if(![annotation isKindOfClass:[Annotation class]]) // Don't mess user location return nil; static NSString *defaultPinID = @"StandardIdentifier"; pinView = (MKAnnotationView *)[self.mapView dequeueReusableAnnotationViewWithIdentifier:defaultPinID]; if (pinView == nil){ pinView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:defaultPinID]; } // Build our annotation if ([annotation isKindOfClass:[Annotation class]]) { Annotation *a = (Annotation *)annotation; pinView.image = [ZSPinAnnotation pinAnnotationWithColor:a.color];// ZSPinAnnotation Being Used pinView.annotation = a; pinView.enabled = YES; pinView.centerOffset=CGPointMake(6.5,-16); pinView.calloutOffset = CGPointMake(-11,0); //pinView.animatesDrop = YES; } pinView.canShowCallout = YES; UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; [rightButton setTitle:annotation.title forState:UIControlStateNormal]; [pinView setRightCalloutAccessoryView:rightButton]; pinView.leftCalloutAccessoryView = [[UIView alloc] init]; pinView.leftCalloutAccessoryView=nil; /*UIButton *leftButton = [UIButton buttonWithType:UIButtonTypeInfoLight]; [leftButton setTitle:annotation.title forState:UIControlStateNormal]; [pinView setLeftCalloutAccessoryView:leftButton];*/ return pinView; }

    Read the article

  • Help with iphone button pressed

    - by StealthRT
    I am trying to see which button was clicked on so I can preform the correct logic. This is the code for the buttons: UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(270, 423, 60, 60)]; [button addTarget:self action:@selector(buttonPressedAction:) forControlEvents:UIControlEventTouchUpInside]; [button setBackgroundImage:[[UIImage imageNamed:@"refreshicon.png"] stretchableImageWithLeftCapWidth:10.0 topCapHeight:0.0] forState:UIControlStateNormal]; UIButton *button2 = [[UIButton alloc] initWithFrame:CGRectMake(0, 423, 60, 60)]; [button2 addTarget:self action:@selector(buttonPressedAction:) forControlEvents:UIControlEventTouchUpInside]; [button2 setBackgroundImage:[[UIImage imageNamed:@"login.png"] stretchableImageWithLeftCapWidth:10.0 topCapHeight:0.0] forState:UIControlStateNormal]; [self.navigationController.view addSubview:button]; [self.navigationController.view addSubview:button2]; And this is how I call the buttonPressedAction: - (void)buttonPressedAction:(id)sender { NSLog(@"%@", [sender value]); isRefreshing = TRUE; [self loadTheXML]; [self.tableView reloadData]; } But when I use NSLog to see what the sender value is, it crashes. Any advice for what's happening and how to correct it?

    Read the article

  • UIImagePickerControllerDelegate Returns Blank "editingInfo" Dictionary Object

    - by Leachy Peachy
    Hi there, I have an iPhone app that calls upon the UIImagePickerController to offer folks a choice between selecting images via the camera or via their photo library on the phone. The problem is that sometimes, (Can't always get it to replicate.), the editingInfo dictionary object that is supposed to be returned by didFinishPickingImage delegate message, comes back blank or (null). Has anyone else seen this before? I am implementing the UIImagePickerControllerDelegate in my .h file and I am correctly implementing the two delegate methods: didFinishPickingImage and imagePickerControllerDidCancel. Any help would be greatly appreciated. Thank you in advance! Here is my code... my .h file: @interface AddPhotoController : UIViewController <UIImagePickerControllerDelegate, UINavigationControllerDelegate> { IBOutlet UIImageView *imageView; IBOutlet UIButton *snapNewPictureButton; IBOutlet UIButton *selectFromPhotoLibraryButton; } @property (nonatomic, retain) UIImageView *imageView; @property (nonatomic, retain) UIButton *snapNewPictureButton; @property (nonatomic, retain) UIButton * selectFromPhotoLibraryButton; my .m file: @implementation AddPhotoController @synthesize imageView, snapNewPictureButton, selectFromPhotoLibraryButton; - (IBAction)getCameraPicture:(id)sender { UIImagePickerController *picker = [[UIImagePickerController alloc] init]; picker.delegate = self; picker.sourceType = UIImagePickerControllerSourceTypeCamera; picker.allowsImageEditing = YES; [self presentModalViewController:picker animated:YES]; [picker release]; } - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo { NSLog(@"Image Meta Info.: %@",editingInfo); UIImage *selectedImage = image; imageView.image = selectedImage; self._havePictureData = YES; [self.useThisPhotoButton setEnabled:YES]; [picker dismissModalViewControllerAnimated:YES]; } - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker { [picker dismissModalViewControllerAnimated:YES]; }

    Read the article

  • Loading Views dynamically

    - by Dann
    Case 1: I have created View-based sample application and tried execute below code. When I press on "Job List" button it should load another view having "Back Btn" on it. In test function, if I use [self.navigationController pushViewController:jbc animated:YES]; nothing gets loaded, but if I use [self presentModalViewController:jbc animated:YES]; it loads another view haveing "Back Btn" on it. Case 2: I did create another Navigation Based Applicaton and used [self.navigationController pushViewController:jbc animated:YES]; it worked as I wanted. Can someone please explain why it was not working in Case 1. Does it has something to do with type of project that is selected? @interface MWViewController : UIViewController { } -(void) test; @end @interface JobViewCtrl : UIViewController { } @end @implementation MWViewController (void)viewDidLoad { UIButton* btn = [UIButton buttonWithType:UIButtonTypeRoundedRect]; btn.frame = CGRectMake(80, 170, 150, 35); [btn setTitle:@"Job List!" forState:UIControlStateNormal]; [btn addTarget:self action:@selector(test) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:btn]; [super viewDidLoad]; } -(void) test { JobViewCtrl* jbc = [[JobViewCtrl alloc] init]; [self.navigationController pushViewController:jbc animated:YES]; //[self presentModalViewController:jbc animated:YES]; [jbc release]; } (void)dealloc { [super dealloc]; } @end @implementation JobViewCtrl -(void) loadView { self.view = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]]; self.view.backgroundColor = [UIColor grayColor]; UIButton* btn = [UIButton buttonWithType:UIButtonTypeRoundedRect]; btn.frame = CGRectMake(80, 170, 150, 35); [btn setTitle:@"Back Btn!" forState:UIControlStateNormal]; [self.view addSubview:btn]; } @end

    Read the article

  • Loading views dynamically

    - by Dan
    Case 1: I have created View-based sample application and tried execute below code. When I press on "Job List" button it should load another view having "Back Btn" on it. In test function, if I use [self.navigationController pushViewController:jbc animated:YES]; nothing gets loaded, but if I use [self presentModalViewController:jbc animated:YES]; it loads another view haveing "Back Btn" on it. Case 2: I did create another Navigation Based Applicaton and used [self.navigationController pushViewController:jbc animated:YES]; it worked as I wanted. Can someone please explain why it was not working in Case 1. Does it has something to do with type of project that is selected? @interface MWViewController : UIViewController { } -(void) test; @end @interface JobViewCtrl : UIViewController { } @end @implementation MWViewController (void)viewDidLoad { UIButton* btn = [UIButton buttonWithType:UIButtonTypeRoundedRect]; btn.frame = CGRectMake(80, 170, 150, 35); [btn setTitle:@"Job List!" forState:UIControlStateNormal]; [btn addTarget:self action:@selector(test) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:btn]; [super viewDidLoad]; } -(void) test { JobViewCtrl* jbc = [[JobViewCtrl alloc] init]; [self.navigationController pushViewController:jbc animated:YES]; //[self presentModalViewController:jbc animated:YES]; [jbc release]; } (void)dealloc { [super dealloc]; } @end @implementation JobViewCtrl -(void) loadView { self.view = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]]; self.view.backgroundColor = [UIColor grayColor]; UIButton* btn = [UIButton buttonWithType:UIButtonTypeRoundedRect]; btn.frame = CGRectMake(80, 170, 150, 35); [btn setTitle:@"Back Btn!" forState:UIControlStateNormal]; [self.view addSubview:btn]; } @end

    Read the article

  • Connecting Multiple Buttons to one action?

    - by David
    Hello, I have multiple UIButtons in my app. I also use interfacebuilder. In my .h i have something like this IBOutlet UIButton *button1; IBOutlet UIButton *button2; IBOutlet UIButton *button3; - (IBAction)buttonPressed; Then In my m i want to do something like this (IBAction)buttonPressed { if (theButtonIpressed == button1) { } } The problem is I don't have something called "theButtonIpressed" so I cant do this. What should my if statement look like? Thanks, -David

    Read the article

  • Best practice to pass a value from pop over control on iPad.

    - by Tattat
    It is an iPad app based on SDK 3.2. I have a MainUIView, that is subclass from UIView, it have a UIButton and a UILabel. When user press the UIButton, the pop over control will be appeared with a table view. When the user select a cell from the table view, the UILabel changes content base on the user click, and the pop up table view will disappear. The question is, how can I pass the "selected cell" to the UILabel. I am thinking making a "middle man" object. When the user click the UIButton, and the "middle man" will pass to the table. When the cell is selected, the "middle man" will store the idx, and call the UILabel change content from the value of "middle man". But I think it is pretty complex to implement, is there any easier way to implement it? thz u.

    Read the article

  • iphone - UIViewController header view errors

    - by Fiona
    Hi there, So to give a little background: I've an app that has a UITableViewController- (ContactDetailViewController) In this view at the top, I require a few labels and buttons, followed by a group style tableview. So I've created a nib file containing these elements. (ContactHeaderView.xib) Then in the viewDidLoad of ContactDetailViewController I've loaded this nib as the headerView. See implementation file below: #import "ContactDetailViewController.h" #import "DisplayInfoViewController.h" #import "ActionViewController.h" @implementation ContactDetailViewController @synthesize name; @synthesize date; @synthesize nextAction; @synthesize nameLabel; @synthesize usernameLabel; @synthesize nextActionTextField; @synthesize dateLabel; @synthesize contactInfoButton; @synthesize backgroundInfoButton; @synthesize actionDoneButton; - (void)viewDidLoad { [super viewDidLoad]; } - (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; // Release any cached data, images, etc that aren't in use. } - (void)viewDidUnload { // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; } #pragma mark Table view methods - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } // Customize the number of rows in the table view. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 3; } - (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { if (section == 0){ UIViewController *chv = [[[UIViewController alloc] initWithNibName:@"ContactHeaderView" bundle:nil] autorelease]; // self.nameLabel.text = self.name; return chv.view; }else{ return nil; } } - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{ return 300.0; } // Customize the appearance of table view cells. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; } // Set up the cell... return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { // Navigation logic may go here. Create and push another view controller. // AnotherViewController *anotherViewController = [[AnotherViewController alloc] initWithNibName:@"AnotherView" bundle:nil]; // [self.navigationController pushViewController:anotherViewController]; // [anotherViewController release]; } /* // Override to support conditional editing of the table view. - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { // Return NO if you do not want the specified item to be editable. return YES; } */ - (void)dealloc { [name release]; [date release]; [nextAction release]; [nameLabel release]; [usernameLabel release]; [nextActionTextField release]; [dateLabel release]; [contactInfoButton release]; [backgroundInfoButton release]; [actionDoneButton release]; [super dealloc]; } -(IBAction)displayContactInfo:(id)sender{ DisplayInfoViewController *divc = [[DisplayInfoViewController alloc] init]; divc.textView = self.nextAction; divc.title = @"Contact Info"; [self.navigationController pushViewController:divc animated:YES]; [divc release]; } -(IBAction)displayBackgroundInfo:(id)sender{ DisplayInfoViewController *divc = [[DisplayInfoViewController alloc] init]; divc.textView = self.nextAction; divc.title = @"Background Info"; [self.navigationController pushViewController:divc animated:YES]; [divc release]; } -(IBAction)actionDone:(id)sender{ ActionViewController *avc = [[ActionViewController alloc] init]; avc.title = @"Action"; avc.nextAction = self.nextAction; [self.navigationController pushViewController:avc animated:YES]; [avc release]; } @end Here's the Header File: #import <UIKit/UIKit.h> @interface ContactDetailViewController : UITableViewController { NSString *name; NSString *date; NSString *nextAction; IBOutlet UILabel *nameLabel; IBOutlet UILabel *usernameLabel; IBOutlet UITextField *nextActionTextField; IBOutlet UILabel *dateLabel; IBOutlet UIButton *contactInfoButton; IBOutlet UIButton *backgroundInfoButton; IBOutlet UIButton *actionDoneButton; } @property (nonatomic, retain) NSString *name; @property (nonatomic, retain) NSString *date; @property (nonatomic, retain) NSString *nextAction; @property (nonatomic, retain) IBOutlet UILabel *nameLabel; @property (nonatomic, retain) IBOutlet UILabel *usernameLabel; @property (nonatomic, retain) IBOutlet UITextField *nextActionTextField; @property (nonatomic, retain) IBOutlet UILabel *dateLabel; @property (nonatomic, retain) IBOutlet UIButton *contactInfoButton; @property (nonatomic, retain) IBOutlet UIButton *backgroundInfoButton; @property (nonatomic, retain) IBOutlet UIButton *actionDoneButton; -(IBAction)displayContactInfo: (id)sender; -(IBAction)displayBackgroundInfo: (id)sender; -(IBAction)actionDone: (id)sender; @end However when I run it, I get the following error message: * Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key nameLabel.' In IB I've hooked up the labels/buttons/textbox to the File's Owner (set the File's Owner Class to: ContactDetailViewController) Anyone any idea what I'm doing wrong? Regards, Fiona

    Read the article

  • Best practice to pass a value from pop up control on iPad.

    - by Tattat
    It is an iPad app based on SDK 3.2. I have a MainUIView, that is subclass from UIView, it have a UIButton and a UILabel. When user press the UIButton, the pop up control will be appeared with a table view. When the user select a cell from the table view, the UILabel changes content base on the user click, and the pop up table view will disappear. The question is, how can I pass the "selected cell" to the UILabel. I am thinking making a "middle man" object. When the user click the UIButton, and the "middle man" will pass to the table. When the cell is selected, the "middle man" will store the idx, and call the UILabel change content from the value of "middle man". But I think it is pretty complex to implement, is there any easier way to implement it? thz u.

    Read the article

  • Access a viewControllers View

    - by iFloh
    Hi, I am trying to get to grips with programmatically configuring views. I have a UIViewController and want to add a UIButton to its view. Well, I created the button: UIButton *newViewButton = [[UIButton alloc] initWithFrame:CGRectMake(baseX + viewPlusX, baseY + viewPlusY, viewWidth, viewHeight)]; [newViewButton setTitle:@"View" forState:UIControlStateNormal]; [newViewButton setTag:(int)key]; [newViewButton addTarget:myViewController action:@selector(viewButton:sender) forControlEvents:UIControlEventTouchUpInside]; but when trying to add it to the view [myViewController addSubview:newViewButton]; I get the error error: expected ':' before":" token any clue what I am doing wrong regards

    Read the article

  • vertical scrolling of text in UItextfield

    - by mindfreak
    I am filling Uitextfield with Uibutton click event.(e.g. clicking on BUTTONA will add 'a' to textfield.). my problem is that when inserted text reaches the end of textfield, further characters inserted into textfield via UIbutton are not visible.instead ... is seen . how to let text inside Uitextfield scroll to left when width of UItextfield is reached(just like when we enter characters in UItextfield via keyboard) ? Please let me know.

    Read the article

  • UIControlEventTouchDragExit only fires ~100 pixels out

    - by Jonathan
    Im trying to "get" when a finger/touch leaves a UIButton in objective C for iphone. I was told in another answer to use UIControlEventTouchDragExit however this event only fires when the touch gets about 100 pixels away from the button, whereas I would like it to be immediate. The apple docs say that goes according to the bounds however my understand is the bounds and the frame are the same unless you rotate the UIbutton (or whatever)

    Read the article

  • UIControlEventTouchDragExit only fires ~100 pixels out

    - by Jonathan
    Im trying to "get" when a finger/touch leaves a UIButton in objective C for iphone. I was told in another answer to use UIControlEventTouchDragExit however this event only fires when the touch gets about 100 pixels away from the button, whereas I would like it to be immediate. The apple docs say that goes according to the bounds however my understand is the bounds and the frame are the same unless you rotate the UIbutton (or whatever)

    Read the article

  • How to restrict rightBarButtonItem size in UINavigationBar ?

    - by lefakir
    I create a rightBarButtonItem with this method : - (UIBarButtonItem *)customBarButtonWithSelector:(SEL)callback { UIButton *customButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; customButton.bounds = CGRectMake(0, 0, 30.0f, 30.0f); return [[[UIBarButtonItem alloc] initWithCustomView:customButton] autorelease]; } At execution time the selector is fired when the bar is touched outside the button (near the middle). Is there a way to restrict the event responder in the defined bounds or in a acceptable range ?

    Read the article

  • Interface Builder Does Not Recognize Toolbar Buttons

    - by Sheehan Alam
    I created 4 UIButton's that are Custom and Plain in IB. I added a background image to them and then placed them onto my UIToolbar. I created IBActions and hooked up all of the buttons I did not create @property for the buttons, but 3/4 of them appear on my toolbar and they work. Why isnt my 4th button appearing? If I need to declare an @property for them, will it be a UIToolbarButtonItem or a UIButton?

    Read the article

  • iPhone - extending a class delegate

    - by Digital Robot
    OK, I know how to create a class extension, using something like that: on .h @interface UIButton (myExtensionName) // my extended methods @end and then on .m @implementation UIButton (myExtensionName) // my implementations @end But how do I declare the extended delegates I may create? If this was a normal class I would do @protocol myExtensionName <NSObject> // my delegate declarations @end but how do I do that on a class extension? thanks

    Read the article

  • Keeping the keyboard from obscuring widgets in a form

    - by synic
    In an iPhone app, how do I keep the software keyboard from obscuring buttons, or UITextView fields in a View? I've got the following layout: View -\ UITextView UIButton ... but, the keyboard obscures the button at the bottom when I'm typing in the UITextView. I tried using the following: View -\ UIScrollView -\ UITextView UIButton ... but, the window does not scroll as expected, so the user has no way of clicking the button. How is this normally handled?

    Read the article

  • UITableViewCell repeating problem

    - by cannyboy
    I have a UItableview with cells. Some cells have uilabels and some have uibuttons. The UIbuttons are created whenever the first character in an array is "^". However, the uibuttons repeat when i scroll down (appearing over the uilabel).. and then multiply over the uilabels when I scroll up. Any clues why? My voluminous code is below: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { const NSInteger LABEL_TAG = 1001; UILabel *label; UIButton *linkButton; //NSString *linkString; static NSString *CellIdentifier; UITableViewCell *cell; CellIdentifier = @"TableCell"; cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; label = [[UILabel alloc] initWithFrame:CGRectZero]; [cell.contentView addSubview:label]; [label setLineBreakMode:UILineBreakModeWordWrap]; [label setMinimumFontSize:FONT_SIZE]; [label setNumberOfLines:0]; //[label setBackgroundColor:[UIColor redColor]]; [label setTag:LABEL_TAG]; NSString *firstChar = [[paragraphs objectAtIndex:indexPath.row] substringToIndex:1]; NSLog(@"firstChar %@", firstChar); NSLog(@"before comparison"); if ([firstChar isEqualToString:@"^"]) { // not called NSLog(@"BUTTON"); //[label setFont:[UIFont boldSystemFontOfSize:FONT_SIZE]]; linkButton = [UIButton buttonWithType:UIButtonTypeCustom]; linkButton.frame = CGRectMake(CELL_CONTENT_MARGIN, CELL_CONTENT_MARGIN, 280, 30); [cell.contentView addSubview:linkButton]; NSString *myString = [paragraphs objectAtIndex:indexPath.row]; NSArray *myArray = [myString componentsSeparatedByCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"*"]]; NSString *noHash = [myArray objectAtIndex:1]; [linkButton setBackgroundImage:[UIImage imageNamed:@"linkButton.png"] forState:UIControlStateNormal]; linkButton.adjustsImageWhenHighlighted = YES; [linkButton setTitle:noHash forState:UIControlStateNormal]; linkButton.titleLabel.font = [UIFont systemFontOfSize:FONT_SIZE]; [linkButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; [linkButton setTag:indexPath.row]; [linkButton addTarget:self action:@selector(openSafari:) forControlEvents:UIControlEventTouchUpInside]; //size = [noAsterisks sizeWithFont:[UIFont boldSystemFontOfSize:FONT_SIZE] constrainedToSize:constraint lineBreakMode:UILineBreakModeWordWrap]; [label setBackgroundColor:[UIColor clearColor]]; [label setText:@""]; } cell.selectionStyle = UITableViewCellSelectionStyleNone; } else { label = (UILabel *)[cell viewWithTag:LABEL_TAG]; NSString *firstChar = [[paragraphs objectAtIndex:indexPath.row] substringToIndex:1]; NSLog(@"firstChar %@", firstChar); NSLog(@"before comparison"); if ([firstChar isEqualToString:@"^"]) { NSLog(@"cell not nil, reusing linkButton"); linkButton = (UIButton *)[cell viewWithTag:indexPath.row]; } } if (!label) label = (UILabel*)[cell viewWithTag:LABEL_TAG]; NSString *textString = [paragraphs objectAtIndex:indexPath.row]; NSString *noAsterisks = [textString stringByReplacingOccurrencesOfString:@"*" withString:@""] ; CGSize constraint = CGSizeMake(CELL_CONTENT_WIDTH - (CELL_CONTENT_MARGIN * 2), 20000.0f); CGSize size; NSString *firstChar = [[paragraphs objectAtIndex:indexPath.row] substringToIndex:1]; //NSLog(@"firstChar %@", firstChar); if ([firstChar isEqualToString:@"^"]) { NSLog(@"BUTTON2"); if (!linkButton) linkButton = (UIButton*)[cell viewWithTag:indexPath.row]; linkButton = [UIButton buttonWithType:UIButtonTypeCustom]; linkButton.frame = CGRectMake(CELL_CONTENT_MARGIN, CELL_CONTENT_MARGIN, 280, 30); [cell.contentView addSubview:linkButton]; NSString *myString = [paragraphs objectAtIndex:indexPath.row]; NSArray *myArray = [myString componentsSeparatedByCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"*"]]; NSString *noHash = [myArray objectAtIndex:1]; [linkButton setBackgroundImage:[UIImage imageNamed:@"linkButton.png"] forState:UIControlStateNormal]; linkButton.adjustsImageWhenHighlighted = YES; [linkButton setTitle:noHash forState:UIControlStateNormal]; linkButton.titleLabel.font = [UIFont systemFontOfSize:FONT_SIZE]; [linkButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; [linkButton setTag:indexPath.row]; [linkButton addTarget:self action:@selector(openSafari:) forControlEvents:UIControlEventTouchUpInside]; size = [noAsterisks sizeWithFont:[UIFont boldSystemFontOfSize:FONT_SIZE] constrainedToSize:constraint lineBreakMode:UILineBreakModeWordWrap]; [label setBackgroundColor:[UIColor clearColor]]; [label setText:@""]; } else if ([firstChar isEqualToString:@"*"]) { size = [noAsterisks sizeWithFont:[UIFont boldSystemFontOfSize:FONT_SIZE] constrainedToSize:constraint lineBreakMode:UILineBreakModeWordWrap]; [label setFont:[UIFont boldSystemFontOfSize:FONT_SIZE]]; [label setText:noAsterisks]; NSLog(@"bold"); } else { size = [noAsterisks sizeWithFont:[UIFont systemFontOfSize:FONT_SIZE] constrainedToSize:constraint lineBreakMode:UILineBreakModeWordWrap]; [label setFont:[UIFont systemFontOfSize:FONT_SIZE]]; [label setText:noAsterisks]; } [label setFrame:CGRectMake(CELL_CONTENT_MARGIN, CELL_CONTENT_MARGIN, CELL_CONTENT_WIDTH - (CELL_CONTENT_MARGIN * 2), MAX(size.height, 20.0f))]; cell.selectionStyle = UITableViewCellSelectionStyleNone; cell.accessoryType = UITableViewCellAccessoryNone; return cell; }

    Read the article

  • iphone xcode annotation pin drop with slider value change also remove

    - by chirag
    i have to add annotation pin on location with UIslider Value change .... this is code where i add annotation (MKAnnotationView *) mapView:(MKMapView *)mapView1 viewForAnnotation:(id ) annotation{ MKAnnotationView* annotationView = nil; NSString* identifier = @"Pin"; MyAnnotationView* annView = (MyAnnotationView*)[mapView1 dequeueReusableAnnotationViewWithIdentifier:identifier]; // annotationView.leftCalloutAccessoryView = myImage; //myImage = [UIButton buttonWithType:UIButtonTypeCustom]; // [myImage setImage:[UIImage imageNamed:@"mark.png"]forState:UIControlStateNormal]; //Property_Photo UIButton *mybtn = [UIButton buttonWithType:UIButtonTypeCustom]; if([annotation isKindOfClass:[AddressAnnotation class]]){ AddressAnnotation x=(AddressAnnotation)annotation; mybtn.frame = CGRectMake(0, 0, 35, 35); mybtn.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter; mybtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter; [mybtn setImage:[UIImage imageNamed:@"btn.png"] forState:UIControlStateNormal]; [mybtn setTitle:[NSString stringWithFormat:@"%@",[x getID]] forState:UIControlStateDisabled]; [mybtn addTarget:self action:@selector(btnShowProperty:) forControlEvents:UIControlEventTouchUpInside]; ((IMOVEISAppDelegate*)[[UIApplication sharedApplication]delegate]).strPropertyPrice = [[myTblArray objectAtIndex:imgIndex]valueForKey:@"Property_Price"]; NSLog(@"property price: %@",((IMOVEISAppDelegate*)[[UIApplication sharedApplication]delegate]).strPropertyPrice); if(nil == annView) { ///if(annView!=nil && [annView retainCount]>0){ [annView release]; annView=nil; } annView = [[[MyAnnotationView alloc] initWithAnnotation:x reuseIdentifier:identifier] autorelease]; if(Objslider.value==10){ [myMapView removeAnnotations:myMapView.annotations]; } } NSURL *imgURL = [NSURL URLWithString:[[myTblArray objectAtIndex:imgIndex]valueForKey:@"Property_Photo"]]; UIImage *imgPhoto = [UIImage imageWithData:[NSData dataWithContentsOfURL:imgURL]]; UIImageView *pinImgView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0,35, 35)]; imgIndex++; [pinImgView setImage:imgPhoto]; annView.rightCalloutAccessoryView = mybtn; annView.leftCalloutAccessoryView = pinImgView; [annView setBackgroundColor:[UIColor clearColor]]; } [annView setEnabled:YES]; annView.canShowCallout = YES; annView.calloutOffset = CGPointMake(-5, 5); annotationView = annView; return annotationView; }

    Read the article

  • add button to navigationbar programatically

    - by mac
    Hi i need to set the button on right side, in navigation bar, programatically , so that if i press the button i will perform some actions, i have created the navigation bar,programatically by navBar=[[UINavigationBar alloc]initWithFrame:CGRectMake(0,0,320,44) ]; similarly i need to add the button , right side of this navigation bar,for that i used, 1) UIView* container = [[UIView alloc] init]; // create a button and add it to the container UIButton* button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 130, 44.01)]; [container addSubview:button]; [button release]; // add another button button = [[UIButton alloc] initWithFrame:CGRectMake(160, 0, 50, 44.01)]; [container addSubview:button]; [button release]; // now create a Bar button item UIBarButtonItem* item = [[UIBarButtonItem alloc] initWithCustomView:container]; // set the nav bar's right button item self.navigationItem.rightBarButtonItem = item; [item release]; 2) UIImage *im; im=[UIImage imageNamed:@"back.png"]; [button setImage:im forState:UIControlStateNormal]; [im release]; backButton = [[UIBarButtonItem alloc] initWithCustomView:button]; [backButton setImageInsets:UIEdgeInsetsMake(0, -10,5, 5)]; [self.navigationItem setRightBarButtonItem:backButton]; 3) UIBarButtonItem *refreshItem = [[UIBarButtonItem alloc] initWithTitle:@"button" style:UIBarButtonItemStylePlain target:self action:@selector(refreshLogsAction:)]; self.navigationItem.rightBarButtonItem = refreshItem; [refreshItem release]; i tried all these type of codings , no use, these codes are not displaying the button at rigth side,please help me. thanks in advance,

    Read the article

< Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >