Search Results

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

Page 6/18 | < Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >

  • How do get the view that is the tapped detail-disclosure-button.

    - by Roberta
    The cell in this iPhone TableView definitely has a Detail-Disclosure-Button. When I tap it... shouldn't this code give me access to the button? Instead detailButton is always just null. - (void) tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath { UITableViewCell *aCell = [tableView cellForRowAtIndexPath:indexPath]; UIButton *detailButton = (UIButton *)[aCell accessoryView]; }

    Read the article

  • UIButtons in UIScrollView stop it scrolling, how to fix?

    - by Mark McFarlane
    Hi all, I have a problem with adding a set of UIButtons to a UIScrollView. With the buttons added it seems that the scroll command is not being passed to the scroll view as the buttons cover the whole surface. I've read various posts on this but still can't figure it out. I'm pretty new to iPhone programming so there's probably something obvious I've missed. I've tried things like canCancelContentTouches and delaysContentTouches to TRUE and FALSE. Here is the code I use to add the buttons to the scrollview. The scrollview was created in IB and is passed in to the function: -(void)drawCharacters:(NSMutableArray *)chars:(UIScrollView *)target_view { //NSLog(@"CLEARING PREVIOUS BUTTONS"); //clear previous buttons for parts/kanji if(target_view == viewParts){ for (UIButton *btn in parts_buttons) { [btn removeFromSuperview]; } [parts_buttons removeAllObjects]; } else if(target_view == viewKanji){ for (UIButton *btn in kanji_buttons) { [btn removeFromSuperview]; } [kanji_buttons removeAllObjects]; } //display options int chars_per_line = 9; //change this to change the number of chars displayed on each line if(target_view == viewKanji){ chars_per_line = 8; } int char_gap = 0; //change this to change the margin between chars int char_dimensions = (320/chars_per_line)-(char_gap*2); //set starting x, y coords int x = 0, y = 0; //increment y coord y += char_gap; //NSLog(@"ABOUT TO DRAW FIRST BUTTON"); for(NSMutableArray *char_arr in chars){ //increment x coord x += char_gap; //draw at x and y UIButton *myButton = [UIButton buttonWithType:UIButtonTypeCustom]; myButton.frame = CGRectMake(x, y, char_dimensions, char_dimensions); // position in the parent view and set the size of the button [myButton setTitle:[char_arr objectAtIndex:0] forState:UIControlStateNormal]; [myButton setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal]; [myButton setTitleColor:[UIColor colorWithRed:0.8 green:0.8 blue:0.8 alpha:1.0] forState:UIControlStateDisabled]; myButton.titleLabel.font = [UIFont boldSystemFontOfSize:22]; if(target_view == viewKanji){ myButton.titleLabel.font = [UIFont boldSystemFontOfSize:30]; } // add targets and actions if(target_view == viewParts){ [myButton addTarget:self action:@selector(partSelected:) forControlEvents:UIControlEventTouchUpInside]; } else if(target_view == viewKanji){ [myButton addTarget:self action:@selector(kanjiSelected:) forControlEvents:UIControlEventTouchUpInside]; [myButton setTag:(int)[char_arr objectAtIndex:1]]; } //if the part isnt in the current list of kanji, disable and dim it if(target_view == viewParts){ if([kanji count] > 0){ [myButton setEnabled:NO]; } bool do_break = NO; for(NSMutableArray *arr in kanji){ //NSLog([NSString stringWithFormat:@"CHECKING PARTS AGAINST %d KANJI", [kanji count]]); for(NSString *str in [[arr objectAtIndex:2] componentsSeparatedByString:@" "]){ if(([myButton.titleLabel.text isEqualToString:str])){ //NSLog(@"--------------MATCH!!!-----------------"); [myButton setEnabled:YES]; for(NSString *str1 in parts_selected){ if(([myButton.titleLabel.text isEqualToString:str1])){ [myButton setEnabled:NO]; break; } } do_break = YES; break; } if(do_break) break; } if(do_break) break; } } // add to a view [target_view addSubview:myButton]; //update coords of next button x += char_dimensions+ char_gap; if (x > (320-char_dimensions)) { x = 0; y += char_dimensions + (char_gap*2); } //add button to global array to be removed from view next update if(target_view == viewParts){ [parts_buttons addObject:myButton]; } else if(target_view == viewKanji){ [kanji_buttons addObject:myButton]; } } //NSLog(@"FINISHED DRAWING ALL BUTTONS"); } Any help on this would be greatly appreciated. I just need to fix this to finish my app.

    Read the article

  • UIButton on UIScrollView can't work

    - by william-hu
    Hi, i used UILabel *myLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 180, 180)]; myLabel.backgroundColor = [UIColor greenColor]; [self.view addSubview:myLabel]; UIButton *myButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [self addTarget:self action:@selector(show) forControlEvents:UIControlEventTouchDown]; myButton.frame = CGRectMake(80.0, 120.0, 30, 30); myButton.showsTouchWhenHighlighted = YES; [self addSubview:myButton]; in this way the button works(call show:), but use [myLabel addSubview:myButton]; the button can't work. who can tell me why? I have tried to change the target to myLabel, can't work too.So who can tell me,thank you. By the way , i want to use the button on the UILabel,and the UILabel on UIScrollView.Thanks a lot!

    Read the article

  • Problem adding subviews (UIButtons) to subclass of UIImageView

    - by samfu_1
    I'm adding a custom button/keypad to my application. Thus far, I have a UIImageView subclass that contains an animation that slides it from the bottom of the screen, and then back down when the user no longer needs it. I'm having trouble adding UIButtons to this UIImageView, however. Since this is a subclass of UIView, I'm attempting to add buttons to my view via the initWithFrame: method. (slideDown method is the added animation) in my UIImageView Subclass, I have a UIButton ivar object added: -(id)initWithFrame:(CGRect)frame { if (self = [super initWithFrame: frame]) { UIButton *button = [UIButton buttonWithType: UIButtonTypeRoundedRect]; button.frame = CGRectMake(16.0, 20.0, 50.0, 50.0); [button setTitle: @"Go" forState: UIControlStateNormal]; [button addTarget: self action: @selector(slideDown) forControlEvents: UIControlEventTouchUpInside]; self.button1 = button; [self addSubview: button1]; NSLog(@"Button added"); } return self; } In my view controller, I instantiate my UIIMageView Subclass in the -(void)viewDidLoad: method as follows: -(void)viewDidLoad { //other objects init'ed ButtonPad *customPad = [[ButtonPad alloc] initWithImage: [UIImage imageNamed: @"ButtonPad.png"]]; customPad.frame = CGRectMake(0.0, 480.0, 320.0, 300.0); self.buttonPad = customPad; [self.view addSubview: buttonPad]; [customPad release]; [super viewDidLoad]; } My current app allows the view to slide up and down off of the screen without any problems. However, the button never appears. I have also tried adding the button to my buttonPad object by instantiating & adding it as a subView to the buttonPad in my view controller file. This worked... but it didn't allow the button to function. I am wondering: A.) Is it appropriate to add buttons or any subview for that matter to the UIView initWithFrame: method or should I be adding these subviews as a subview to my buttonPad in the view Controller file? B.) Since I am creating a custom button/keypad, am i following a valid approach by using a normal UIViewController or should I be using something like a modal view Controller? ( I have little knowledge about these.)

    Read the article

  • Why is UIControlTouchUpInside UNDEFINED?

    - by munchine
    I've got a simple question but it has got me confounded. The code below gets an UNDEFINED error for UIControlTouchUpInside. What do I need to include or import? If I comment out the line, it works. So that means forState:UIControlStateNormal is defined. I'm new so hope you can help. UIButton * button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [button setTitle:@"Accept?" forState:UIControlStateNormal]; [button addTarget:self action:@selector(acceptTapped) forControlEvents:UIControlTouchUpInside];

    Read the article

  • Setting UITableViewCell button image values during scrolling

    - by Rob
    I am having an issue where I am trying to save whether a repeat image will show selected or not (it is created as a UIButton on a UITableViewCell created in IB). The issue is that since the cell gets re-used randomly, the image gets reset or set somewhere else after you start scrolling. I've looked all over and the advice was to setup an NSMutableArray to store the button's selection state and I am doing that in an array called checkRepeatState My question is: where do I put the if-then-else statement in the code to where it will actually change the button image based on if the checkRepeatState is set to 0 or 1 for the given cell that is coming back into view? Right now, the if-then-else statement I am using has absolutely no effect on the button image when it comes into view. I'm very confused at this point. Thank you ahead of time for any insight you can give!!! My code is as follows: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { // set up the cell static NSString *CellIdentifier = @"PlayerCell"; PlayerCell *cell = (PlayerCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (!cell) { [[NSBundle mainBundle] loadNibNamed:@"PlayerNibCells" owner:self options:nil]; cell = tmpCell; self.tmpCell = nil; NSLog(@"Creating a new cell"); } // Display dark and light background in alternate rows -- see tableView:willDisplayCell:forRowAtIndexPath:. cell.useDarkBackground = (indexPath.row % 2 == 0); // Configure the data for the cell. NSDictionary *dataItem = [soundCategories objectAtIndex:indexPath.row]; UILabel *label; label = (UILabel *)[cell viewWithTag:1]; label.text = [dataItem objectForKey:@"AnimalName"]; label = (UILabel *)[cell viewWithTag:2]; label.text = [dataItem objectForKey:@"Description"]; UIImageView *img; img = (UIImageView *)[cell viewWithTag:3]; img.image = [UIImage imageNamed:[dataItem objectForKey:@"Icon"]]; NSInteger row = indexPath.row; NSNumber *checkValue = [checkRepeatState objectAtIndex:row]; NSLog(@"checkValue is %d", [checkValue intValue]); // Reusing cell; make sure it has correct image based on checkRepeatState value UIButton *repeatbutton = (UIButton *)[cell viewWithTag:4]; if ([checkValue intValue] == 1) { NSLog(@"repeatbutton is selected"); [repeatbutton setImage:[UIImage imageNamed:@"repeatselected.png"] forState:UIControlStateSelected]; [repeatbutton setNeedsDisplay]; } else { NSLog(@"repeatbutton is NOT selected"); [repeatbutton setImage:[UIImage imageNamed:@"repeat.png"] forState:UIControlStateNormal]; [repeatbutton setNeedsDisplay]; } cell.accessoryType = UITableViewCellAccessoryNone; return cell; }

    Read the article

  • Why is forControlEvents UNDEFINED?

    - by munchine
    Hi Guys, I've got a simple question but it has got me confounded. The code below gets a UNDEFINED error for UIControlTouchUpInside. What do I need to include or import? If I comment out the line, it works. So that means forState:UIControlStateNormal is defined. I'm new so hope you can help. UIButton * button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [button setTitle:@"Accept?" forState:UIControlStateNormal]; [button addTarget:self action:@selector(acceptTapped) forControlEvents:UIControlTouchUpInside]; button.frame = CGRectMake(225.0, 145.0, 80.0, 30.0); [self.view addSubview:button];

    Read the article

  • UITableView subview to uitableviewcell

    - by Dave
    i am trying to add a button to the tableview and no matter what frame i specify the button is not visible. This is a custom UITableViewCell and I am adding the button in the code rather than in the xib file is so that I can click on the button and perform an action which is not didSelectRowAtIndexPath: I have the following code in cellForRowAtIndexPath: What am I missing? UIButton *button = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; button.titleLabel.text = @"detail"; button.frame = bframe; button.userInteractionEnabled = YES; [button addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside]; [cell.contentView addSubview:button]; return cell;

    Read the article

  • application Crash when assign multiple argu fun to dynamic button

    - by AJPatel
    for (int i=0;i<[tableDataSource count];i++) { NSDictionary *dict = [tableDataSource objectAtIndex:i]; rowText = [dict objectForKey:@"title"]; UIButton *btn = [UIButton buttonWithType: UIButtonTypeRoundedRect]; [btn setTitle:rowText forState:UIControlStateNormal]; [btn addTarget:self action:@selector(myActionbtnText:) forControlEvents:UIControlEventTouchUpInside]; btn.frame = CGRectMake(60, 40+2*(40*i), 200, 40); btn.alpha = 0.81; [self.view addSubview:btn]; } I got error at assign Action to dynamic button MY action is given Below -(void) myAction:(NSString *)btnText; { NSLog(@"%@ Button Clicked",btnText); }

    Read the article

  • How to change size of UIButton

    - by Adam
    I'm trying to resize a UIButton in my iPhone app. I have a UIButton synthesized and when I call the following code, it moves on the screen, but the width & height of the button never change. button.frame.size = CGRectMake(104, 68, 158, 70); For example, when I change the height (70) to 40, the height of the button does not change. If I change the x or y, however, it will move on the screen. Any ideas?

    Read the article

  • iPhone UIScrollview with UIButtons - how to recreate springboard?

    - by Patrick
    I'm trying to create a springboard-like interface within my app. I'm trying to use UIButtons added to a UIScrollView. The problem I'm running in to is with the buttons not passing any touches to the UIScrollView - if I try to flick/slide and happen to press on the button it doesn't register for the UIScrollView, but if I flick the space between buttons it will work. The buttons do click/work if I touch them. Is there a property or setting that forces the button to send the touch events up to its parent (superview)? Do the buttons need to be added to something else before being added the UIScrollView? Here is my code: //init scrolling area UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 480, 480)]; scrollView.contentSize = CGSizeMake(480, 1000); scrollView.bounces = NO; scrollView.delaysContentTouches = NO; //create background image UIImageView *rowsBackground = [[UIImageView alloc] initWithImage:[self scaleAndRotateImage:[UIImage imageNamed:@"mylongbackground.png"]]]; rowsBackground.userInteractionEnabled = YES; //create button UIButton *btn = [[UIButton buttonWithType:UIButtonTypeCustom] retain]; btn.frame = CGRectMake(100, 850, 150, 150); btn.bounds = CGRectMake(0, 0, 150.0, 150.0); [btn setImage:[self scaleAndRotateImage:[UIImage imageNamed:@"basicbutton.png"]] forState:UIControlStateNormal]; [btn addTarget:self action:@selector(buttonClick) forControlEvents:UIControlEventTouchUpInside]; //add "stuff" to scrolling area [scrollView addSubview:rowsBackground]; [scrollView addSubview:btn]; //add scrolling area to cocos2d //this is just a UIWindow [[[Director sharedDirector] openGLView] addSubview:scrollView]; //mem-mgmt [rowsBackground release]; [btn release]; [scrollView release];

    Read the article

  • UIScrollView only works if the child views aren't hit

    - by dny238
    I have a scroll view that doesn't scroll right, I've simplified the code for below. It draws the view and some horizontal buttons that i add more stuff to in the real code. If you drag the whitespace between the buttons the view scrolls. If you happen to put your finger on a button, it won't scroll. After a related suggestion, I tried to add the delaysContentTouches = YES line, but it doesn't seem to make a difference. http://stackoverflow.com/questions/650437/iphone-uiscrollview-with-uibuttons-how-to-recreate-springboard What am I doing wrong? TIA, Rob Updated the code - (void)viewDidLoad { l = [self landscapeView]; [self.view addSubview:l]; [l release]; } - (UIScrollView *) landscapeView { // LANDSCAPE VIEW UIScrollView *landscapeView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 325)]; landscapeView.backgroundColor = [UIColor whiteColor]; landscapeView.delaysContentTouches = YES; NSInteger iMargin, runningY, n; iMargin = 3; runningY = iMargin; for (n = 1; n <= 38; n++) { //add day labels UIButton *templabel = [[UIButton alloc] initWithFrame:CGRectMake(iMargin,runningY,320 - ( 2 * iMargin),20)]; templabel.backgroundColor = [UIColor grayColor]; [landscapeView addSubview:templabel]; [templabel release]; runningY = runningY + 30; } landscapeView.contentSize = CGSizeMake( 320, runningY); return landscapeView; }

    Read the article

  • is this uibutton autoreleased ?

    - by dubbeat
    HI This is just a question to check my sanity really. I'm hunting memory leaks that show up in instruments but not the static analyzer. In one spot the analyzer is pointing to this block of code UIButton *randomButton = [UIButton buttonWithType:UIButtonTypeRoundedRect ]; randomButton.frame = CGRectMake(205, 145, 90, 22); // size and position of button [randomButton setTitle:@"Random" forState:UIControlStateNormal]; randomButton.backgroundColor = [UIColor clearColor]; randomButton.adjustsImageWhenHighlighted = YES; [randomButton addTarget:self action:@selector(getrandom:) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:randomButton]; For some reason I thought the above code would auto release the button because I'm not calling init or alloc? If I add [randombutton release] at the bottom of the code my button fails to show. Could somebody describe to me the correct way to release a button from memory that is created in the above way? Or would I be better off making the button a class variable and sticking the release in the dealloc method?

    Read the article

  • Is it possible to accept a button tag to be in some range iphone sdk

    - by neha
    Hi all, In my application I'm doing dynamic resizing of cells and label in it depending upon the text in it. I'm adding button to cells in uitableview. I'm taking the label instance and button instance in a new label and button variable respectively and setting their frames to arrange them properly after resizing. if(cel==nil) { //some code original_label=[[UILabel alloc]init]; original_label.tag=111; //SOME MORE CODE GOES HERE original_button=[[UIButton alloc]init]; original_button.tag=222; //SOME MORE CODE GOES HERE } new_label=(UILabel *) [cell viewWithTag:111]; //This' how I'm taking the label instance on cell and below button instance on cell in new variables new_button = (UIButton * ) [cell viewWithTag:222]; Earlier I kept the tags of all the buttons on cells same, so it was easier to get button instances on cells properly and were being arranged properly. But now I want to recognize these buttons separately as I'm adding some functionality on button_click. I'm giving the buttons that are added to the cells incremental tags[1,2,3...9 and so on]. Now, how can I take these button tags in some range like[suppose 1-9]? Can anybody help? Thanks in advance.

    Read the article

  • Giving another object a NSManagedObject

    - by Wayfarer
    Alright, so I'm running into an issue with my code. What I have done is subclassed UIButton so I can give it some more infomormation that pertain to my code. I have been able to create the buttons and they work great. Capiche. However, one of the things I want my subclass to hold is a reference to a NSMangedObject. I have this code in my header file: @interface ButtonSubclass : UIButton { NSManagedObjectContext *context; NSManagedObject *player; } @property (nonatomic, retain) NSManagedObject *player; @property (nonatomic, retain) NSManagedObjectContext *context; - (id)initWithFrame:(CGRect)frame andTitle:(NSString*)title; //- (void)setPlayer:(NSManagedObject *)aPlayer; @end As you can see, it has a instance variable to the NSMangedobject I want it to hold (as well as the Context). But for the life of me, I can't get it to hold that NSManagedObject. I run both the @synthesize methods in the Implementation file. @synthesize context; @synthesize player; So I'm not sure what I'm doing wrong. This is how I create my button: ButtonSubclass *playerButton = [[ButtonSubclass alloc] initWithFrame:frame andTitle:@"20"]; //works playerButton.context = self.context; //works playerButton.player = [players objectAtIndex:i]; //FAILS And I have initilaized the players array earlier, where I get the objects. Another weird thing is that when it gets to this spot in the code, the app crashes (woot) and the the console output stops. It doesn't give me any error, and notification at all that the app has crashed. It just... stops. So I don't even know what the error is that is crashing the code, besides it has to do with that line up there setting the "player" variable. Thoughts and ideas? I'd love your wisdom!

    Read the article

  • accessing a method from a button within a class?

    - by flo
    #import "GameObject.h" #import "Definitions.h" @implementation GameObject @synthesize owner; @synthesize state; @synthesize mirrored; @synthesize button; @synthesize switcher; - (id) init { if ( self = [super init] ) { [self setOwner: EmptyField]; button = [UIButton buttonWithType:UIButtonTypeCustom]; [self setSwitcher: FALSE]; } return self; } - (UIButton*) display{ button.frame = CGRectMake(0, 0, GO_Width, GO_Height); [button setBackgroundImage:[UIImage imageNamed:BlueStone] forState:UIControlStateNormal]; [button addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside]; return button; } -(void)buttonPressed:(id) sender { //... } } - (void) dealloc { [super dealloc]; } @end Hi! i would like to know if the above is possible somehow within a class (in my case it is called GameObject) or if i HAVE to have the button call a methode in the viewcontroller... the above results with the app crashing. i would call display within a loop on the viewcontroller and id like to change some of the GameObjects instance variables within buttonPressed. Also id like to change some other stuff by calling some other methods from within buttonPressed but i think that will be the lesser of my problems ;) also id like to know how i can pass some variables to the buttonPressed method... cant find it anywhere :( help on this one would be much appreciated ;) thanks flo

    Read the article

  • UiButton / IBAction - link from a RootView to mainView in Storyboard

    - by webschnecke
    I try to call the main ViewController on my storyboard. In my app there is a additional .h, .m file with no xib or storyboard. In this .m file T craeted a button: UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [button addTarget:self action:@selector(home:)forControlEvents:UIControlEventTouchDown]; [button setTitle:@"Show View" forState:UIControlStateNormal]; button.frame = CGRectMake(80.0, 210.0, 160.0, 40.0); [self.view addSubview:button]; NSLog(@"Home-Button line 645"); This button should link to my main ViewController in the Storyboard. The view has the identifier HauptMenu. I got no error, but the view doesnt change to my main ViewController. What is wrong? - (IBAction)home:(id)sender { NSLog(@"Button was tapped"); ViewController *viewController = [self.storyboard instantiateViewControllerWithIdentifier:@"HauptMenu"]; NSLog(@"1"); [viewController setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal]; NSLog(@"2"); [self.navigationController pushViewController:viewController animated:NO]; [viewController release]; NSLog(@"3"); }

    Read the article

  • UIButton doesn't appear on UIToolbar

    - by Sheehan Alam
    I have a UIToolbar where I have dragged a UIButton. When I set the button properties to Custom, and assign an image (or background image) the graphics don't appear. However, when I give it a custom text, the text will appear. Why is it that the images don't appear?

    Read the article

  • detail disclosure indicator on UIButton

    - by Ben Collins
    Is there a simple way to place a detail disclosure icon on a UIButton? I'm using a navigation controller and I want a button press to push a new view on the stack, so I thought a detail disclosure icon would be appropriate, but I haven't found a straightforward way to do that yet.

    Read the article

< Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >