Search Results

Search found 36 results on 2 pages for 'uiswitch'.

Page 1/2 | 1 2  | Next Page >

  • Handling multiple UISwitch controls in a table view without using tag property

    - by Thaurin
    I have a table view controller with multiple UISwitch controls in them. I set the delegate to the table view controller with the same action for all switches. I need to be able to determine what switch was changed, so I create an array of strings that contains the name of each switch. The indexes in the array will be put in the tag property of each UISwitch. However, I'm ready using the tag property for something else, namely to find the right control in the cell in cellForRowAtIndexPath with viewWithTag! (There are several things I need to set within each cell.) So, am I thinking along the right lines here? I feel I'm rather limited in how I find out exactly which UISwitch changed its value, so I can do something useful with it.

    Read the article

  • UISwitch not tapped on right area

    - by beryllium
    I placed UISwitch on main view. Now I try change state. But the state changed only when I touch on the left side of the UISwitch. and never on the right. For example in Settings App the airplane mode chanhed any of those ways. Can anybody help me?

    Read the article

  • how to set objectForKey to UISwitch to access switch for save selected option

    - by Rkm
    SystemUIViewcontroller has button event. Tap on Button fire InfoTableviewController. InfoTableview has UISwitch. How to set objectForKey to Info to access UIswitch ViewDidload of System... - (void)viewDidLoad { [super viewDidLoad]; self.Infoarray = [NSMutableArray array]; Info *info = [[Info alloc]initWithNibName:@"Info" bundle:nil]; [self.Infoarray addObject:[NSDictionary dictionaryWithObjectsAndKeys:info, @"viewController", nil]]; } SystemUIviewcontroller button event... -(IBAction) Info_Button_Clicked:(id) sender { Info *info = [[Info alloc]initWithNibName:@"Info" bundle:[NSBundle mainBundle]]; [self.navigationController pushViewController:info animated:YES]; [info release]; } Here for Info TableviewController... - (void)viewDidLoad { [super viewDidLoad]; self.Soundarray = [NSArray arrayWithObjects: [NSDictionary dictionaryWithObjectsAndKeys: @"Sounds", @"labelKey", self.SoundsswitchCtl, @"viewKey", nil],nil]; } // Customize the appearance of table view cells. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = nil; if ([indexPath section] == 0) { static NSString *kDisplayCell_ID = @"DisplayCellID"; cell = [self.tableView dequeueReusableCellWithIdentifier: kDisplayCell_ID]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier: kDisplayCell_ID] autorelease]; cell.selectionStyle = UITableViewCellSelectionStyleNone; } else { // the cell is being recycled, remove old embedded controls UIView *viewToRemove = nil; viewToRemove = [cell.contentView viewWithTag:1]; if (viewToRemove) [viewToRemove removeFromSuperview]; } cell.textLabel.text = [[self.Soundarray objectAtIndex: indexPath.row] valueForKey:@"labelKey"]; UIControl *control = [[self.Soundarray objectAtIndex: indexPath.row] valueForKey:@"viewKey"]; [cell.contentView addSubview:control]; return cell; } } - (UISwitch *)SoundsswitchCtl { if (SoundsswitchCtl == nil) { CGRect frame = CGRectMake(198.0, 12.0, 94.0, 27.0); SoundsswitchCtl = [[UISwitch alloc] initWithFrame:frame]; [SoundsswitchCtl addTarget:self action:@selector(switch_Sounds:) forControlEvents:UIControlEventValueChanged]; // in case the parent view draws with a custom color or gradient, use a transparent color SoundsswitchCtl.backgroundColor = [UIColor clearColor]; [SoundsswitchCtl setAccessibilityLabel:NSLocalizedString(@"StandardSwitch", @"")]; SoundsswitchCtl.tag = 1; // tag this view for later so we can remove it from recycled table cells } return SoundsswitchCtl; }

    Read the article

  • how to set UISwitch pointer to access switch from one uiviewcontroller another uiviewcontroller

    - by Rkm
    System UIViewcontroller has button event.Tap on Button fire InfoTableviewController. InfoTableview has UISwitch . How to set NSMutableArray of UIswitch pointer for System UIViewcontroller to access switch . SystemUIviewcontroller button event - (IBAction) Info_Button_Clicked:(id) sender { // pushcontroller Info *info = [[Info alloc]initWithNibName:@"Info" bundle:[NSBundle mainBundle]]; [self.navigationController pushViewController:info animated:YES]; [info release]; } Here for Info TableviewController // Customize the appearance of table view cells. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = nil; if ([indexPath section] == 0) { static NSString *kDisplayCell_ID = @"DisplayCellID"; cell = [self.tableView dequeueReusableCellWithIdentifier: kDisplayCell_ID]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier: kDisplayCell_ID] autorelease]; cell.selectionStyle = UITableViewCellSelectionStyleNone; } else { // the cell is being recycled, remove old embedded controls UIView *viewToRemove = nil; viewToRemove = [cell.contentView viewWithTag:1]; if (viewToRemove) [viewToRemove removeFromSuperview]; } cell.textLabel.text = [[self.Soundarray objectAtIndex: indexPath.row] valueForKey:@"labelKey"]; UIControl *control = [[self.Soundarray objectAtIndex: indexPath.row] valueForKey:@"viewKey"]; [cell.contentView addSubview:control]; return cell; } }

    Read the article

  • UISwitch propagate state

    - by Reonarudo
    Hello, I'm still rather new to iPhone development and I tried something I didn't it was possible. I have a UIView for my TableView Section Header with a switch on it, and I also have a UITableCellView with another Switch on it. It all looks fine, but now I want to propagate the UISwitch state from the section header to all the UISwitches on the section rows. Can anyone enlighten me how can I accomplish this? Thank you.

    Read the article

  • UISwitch quick toggle multiple times.

    - by Tejaswi Yerukalapudi
    I was playing around my app and I was toggling a UISwitch really fast (who can resist?). So, I toggled it really fast for 10-15 times, an array that should contain the data from the table view cell that I have my switch in either has extra copies of the same cell sometimes, just one copy (the correct case) a few times and no data in it at all some times. The app works fine if it's toggled at normal speed. I'm pretty sure this scenario won't really happen with my users, but I'm still curious as to why it's happening. Thanks, Teja

    Read the article

  • How to tell when a UISwitch inside of a UITableViewCell has been tapped?

    - by RexOnRoids
    How to tell when a UISwitch inside of a UITableViewCell has been tapped? My UISwitch is set up inside of the cell (generic cell) like this: UISwitch *mySwitch = [[[UISwitch alloc] initWithFrame:CGRectZero] autorelease]; [cell addSubview:mySwitch]; cell.accessoryView = mySwitch; And I am trying to detect a tap like this (but its not working): - (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath { NSUserDefaults *prefs; if(indexPath.section == 1){ switch(indexPath.row) { case 0: NSLog(@"Tapped Login Switch"); break; default: break; } } }

    Read the article

  • Why is -[UISwitch superlayer] being called?

    - by Jonathan Sterling
    I've got sort of a crazy thing going on where I have an NSProxy subclass standing in for a UISwitch. Messages sent to the proxy are forwarded to the switch. Please don't comment on whether or not this is a good design, because in context, it makes sense as an incredibly cool thing. The dealio is that when I try to add this object as an accessory view to a UITableViewCell, I get the following crash: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[UISwitch superlayer]: unrecognized selector sent to instance 0x5889740' Yes, I could just set the proxy's target as the accessory view, but then I would have to keep track of the proxy so that I could release it at the right time. So, what I really want is to be able to have the proxy retained by the table cell, and released when it is removed from the view just like a normal accessory view. So, why is -[UISwitch superlayer] (a method which does not exist) being called, and how do I save the world?

    Read the article

  • UISwitch within UIScrollview nearly impossible to use....

    - by samsam
    Hi there. I'm using a UISwitch-Component at the bottom of a view that sits within a UIScrollView. Now the problem that appeared, is that the switch is nearly impossible to swipe because the UIScrollView seems to dominate the userinput. Switching works very well by tapping the switch, but from my point of view, most users "switch" the UISwitch instead of tapping. Did anyone of you face the same / or similar problems and managed to come up with a solution? thx in advance sam

    Read the article

  • How save selected switch option

    - by Rkm
    System UIviewcontroller has button , Tap on button i need to fire Info Tableviewcontroller. Tableviewcontroller itself UISwitch. My question is I need to save last selected switch option ON/OFF in UISwitch how to set my control. @implementation Info // 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]; } if (indexPath.section) { cell.textLabel.text = @"Sounds"; cell.selectionStyle = UITableViewCellSelectionStyleNone; UISwitch *switchView = [[UISwitch alloc] initWithFrame:CGRectZero]; cell.accessoryView = switchView; [switchView setOn:NO animated:NO]; [switchView addTarget:self action:@selector(switchChanged_Sounds:) forControlEvents:UIControlEventValueChanged]; [switchView release]; return cell ; } } - (void) switchChanged_Sounds:(id)sender { UISwitch* switchControl = sender; NSLog( @"The switchChanged_Sounds is %@", switchControl.on ? @"ON" : @"OFF" ); }

    Read the article

  • How to resize a UISwitch?

    - by mshsayem
    I have made a custom UISwitch (from this post). But the problem is, my custom texts are a bit long. Is there any way to resize the switch? [I tried setBounds, did not work] Edit: Here is the code I used: @interface CustomUISwitch : UISwitch - (void) setLeftLabelText: (NSString *) labelText; - (void) setRightLabelText: (NSString *) labelText; @end @implementation CustomUISwitch - (UIView *) slider { return [[self subviews] lastObject]; } - (UIView *) textHolder { return [[[self slider] subviews] objectAtIndex:2]; } - (UILabel *) leftLabel { return [[[self textHolder] subviews] objectAtIndex:0]; } - (UILabel *) rightLabel { return [[[self textHolder] subviews] objectAtIndex:1]; } - (void) setLeftLabelText: (NSString *) labelText { [[self leftLabel] setText:labelText]; } - (void) setRightLabelText: (NSString *) labelText { [[self rightLabel] setText:labelText]; } @end mySwitch = [[CustomUISwitch alloc] initWithFrame:CGRectZero]; //Tried these, but did not work //CGRect aFrame = mySwitch.frame; //aFrame.size.width = 200; //aFrame.size.height = 100; //mySwitch.frame = aFrame; [mySwitch setLeftLabelText: @"longValue1"]; [mySwitch setRightLabelText: @"longValue2"];

    Read the article

  • iphone - using a UISwitch

    - by Mike
    I need to implement a view where I need the user to answer several questions using YES or NO. I thought of using a UISwitch but as far as I see it does not allows replacing the ON/OFF messages it shows with YES/NO. Am I wrong? I thought of implementing a segmented control with 2 buttons but this is like using a cannon to kill a fly... Any suggestions on how to do that? thanks

    Read the article

  • Custom UISwitch & App Store approval

    - by pix0r
    After doing some reading, I've found that you can customize the text and color on a UISwitch control. I'm curious if these methods will cause problems trying to get my app approved and included in the App Store. Sample code taken from iPhone Developer's Cookbook Sample Code: // Custom font, color switchView = [[UICustomSwitch alloc] initWithFrame:CGRectZero]; [switchView setCenter:CGPointMake(160.0f,260.0f)]; [switchView setLeftLabelText: @"Foo"]; [switchView setRightLabelText: @"Bar"]; [[switchView rightLabel] setFont:[UIFont fontWithName:@"Georgia" size:16.0f]]; [[switchView leftLabel] setFont:[UIFont fontWithName:@"Georgia" size:16.0f]]; [[switchView leftLabel] setTextColor:[UIColor yellowColor]];

    Read the article

  • UISwitch text not showing on device

    - by iFloh
    Hi, I have a screen with several UISwitch controls. On my iPhone simulator this screen works correctly and The Switch text shows as On/Off. Different on my testing device (iPod Touch). Here the text seems to get lost and I only get "1" (instead of "On") and "0" (instead of "Off"). I don't know where the iPod Touch is different and why it's not showing correctly. Anyone had a similar experience? Is this a bug? Cheers

    Read the article

  • Set an Interface Builder created element's state programatically

    - by mvexel
    I have a couple of UISwitch elements in a view controller that is presented modally in my iPhone app. I set up the view in IB. I want these UISwitch elements to reflect the current values in my [NSUserDefaults standardUserDefaults] where I store the appropriate BOOLs. I thought this would do the trick setting the switches to the right state, but no: -(void)viewWillAppear:(BOOL)animated { NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; [backgroundSwitch setOn:[defaults boolForKey:kTrackInBackgroundKey] animated:NO]; [batterySaveSwitch setOn:[defaults boolForKey:kBatterySaveKey] animated:NO]; } The backgroundSwitch and batterySaveSwitch are declared as properties for the view controller class. They are not initialized; that does not seem to make a difference. I did check the values coming out of the NSUserDefaults dictionary. The method is being called at the right time.

    Read the article

  • Detecting if music is playing?

    - by Flafla2
    Hi! My app involves music(iPodMusic), and there is a UISwitch toggling play/pause. My goal is to be able to detect if music is playing, so that therefore the play/pause switch can say 'play' when music is playing and 'pause' if it isn't.

    Read the article

  • iPhone: Save boolean into Core Data

    - by Nic Hubbard
    I have set up one of my core data attributes as a Boolean. Now, I need to set it, but XCode keeps telling me that it may not respond to setUseGPS. [ride setUseGPS: useGPS.on]; What is the method for setting a boolean in core data? All my other attributes are set this way, and they work great. So, not sure why a boolean does not work to be set this way?

    Read the article

  • How to resolve warning about does not implement the 'UIActionSheetDelegate' protocol

    - by RAGOpoR
    here is my .h code @interface ROSettingViewController : UITableViewController { UISwitch *switchCtl; UISwitch *switchCtl1; NSArray *dataSourceArray; } @property (nonatomic, retain, readonly) UISwitch *switchCtl; @property (nonatomic, retain, readonly) UISwitch *switchCtl1; @property (nonatomic, retain) NSArray *dataSourceArray; - (void)dialogOKCancelAction; - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex; @end /Users/ragopor/Desktop/Power Spot beta 2/code/Classes/ROSettingViewController.m:321: warning: class 'ROSettingViewController' does not implement the 'UIActionSheetDelegate' protocol

    Read the article

  • UITableViewCell no userInteraction but on cell.accessoryView

    - by Simon
    hello genius and nerds I have a TableViewCell with a UISwitch in accessoryView. I don't want that blue background if someone selected it. There fore i used cell.userInteractionEnabled = NO; but then the whole cell isnt accessable so i tried that cell.userInteractionEnabled = NO; cell.accessoryView.userInteractionEnabled = YES; i think this wont work because cell is the parent of the accessoryView. but how can i manage this issue ? A hint in the right direction would be great. Simon Here is the complete cellForRowAtIndexPath method: cell.textLabel.text = @"dasda"; cell.userInteractionEnabled = NO; cell.accessoryType = UITableViewCellAccessoryNone; UISwitch *mySwitch = [[[UISwitch alloc] initWithFrame:CGRectZero] autorelease]; mySwitch.tag = row; [cell addSubview:mySwitch]; cell.accessoryView = mySwitch; cell.accessoryView.userInteractionEnabled = YES; [(UISwitch *)cell.accessoryView setOn: YES]; [(UISwitch *)cell.accessoryView addTarget:self action:@selector(someAction:) forControlEvents:UIControlEventValueChanged]; return cell;

    Read the article

  • iPhone vertical toggle switch

    - by nan
    I'm trying to create a vertical toggle switch control for the iPhone (along the lines of UISwitch but vertical sliding). I was wondering whether an existing control already existed or if there are any good tutorials that explain the basics of creating custom controls for the iPhone. Currently I've tried using affine transforms to create the vertical switch from a basic UIswitch, and it works except that the slider is too small compared to the slider track, thus I'm looking for information on writing custom controls. Any direction is much appreciated.

    Read the article

  • Object leak using "retain"

    - by Abhinav
    I have a property defined with retain attribute which I am synthesizing: @property (nonatomic, retain) UISwitch *mySwitch; And inside my loadView I am doing this: self.mySwitch = [[UISwitch alloc] initWithFrame:CGRectMake(0, 0, 40, 20)]; And finally inside my dealloc I am doing this: self.mySwitch = nil; Am I leaking this object (mySwitch) as I have used one alloc? Should I autorelease it while assigning it frame? Please suggest.

    Read the article

  • Getting data from UITableView

    - by Tejaswi Yerukalapudi
    Hi, I have a few custom UITableViewCells - http://img11.imageshack.us/i/customfacilitiescell.png/ which are added to this UIViewController - http://img189.imageshack.us/i/facilitycontroller.png/ Now, on clicking a button in the controller, I'd like to get the on/off status of all the UISwitches in the controller. Thanks, Teja Edit: I've made a few edits, but I still can't figure out how to do this. My program structure currently - A CustomCell.xib that looks like this - http://img11.imageshack.us/i/customfacilitiescell.png/ A CustomCellController that a subclass of UITableViewCell that has the IBOutlets for the labels and switches from above. Now I have a UIViewController<UITableViewDataSource, UITableViewDelegate> (Say, Screen1Controller) which looks like - http://img189.imageshack.us/i/facilitycontroller.png/ The tableviewcell is being created like this - - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *Id= @"CustomFacilitiesCell"; CustomFacilitiesCellController *cell = (CustomFacilitiesCellController *)[tableView dequeueReusableCellWithIdentifier:Id]; if(cell == nil) { NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"CustomFacilitiesCell" owner:self options:nil]; for (id oneObject in nib) { if([oneObject isKindOfClass:[CustomFacilitiesCellController class]]) cell = (CustomFacilitiesCellController *) oneObject; } } NSUInteger row = [indexPath row]; CustomFacilitiesCellController *rowData = (CustomFacilitiesCellController *)[self.facilities objectAtIndex:row]; cell.facname.text = rowData.facname.text; cell.FacID.text = rowData.FacID.text; cell.facSwitch = [(CustomFacilitiesCellController *)rowData facSwitch]; UISwitch *temp = cell.facSwitch; [(UISwitch *)[cell facSwitch] addTarget:self action:@selector(facSwitchOptionChanged:) forControlEvents:UIControlEventValueChanged]; cell.facSwitch.on = NO; //cell.facSwitch.enabled = FALSE; cell.accessoryType = UITableViewCellAccessoryNone; return cell; } - (IBAction) facSwitchOptionChanged:(id) sender { int i=0; } In particular, my problem is that the facSwitchOptionChanged() isn't getting called. Thanks again for the help, Teja.

    Read the article

  • UIActionSheet positioning problem

    - by Dave
    I need to display a pop with a UISwitch and a Done button when user taps on a button and save the state of the switch when the done button in the pop up is tapped. So I use UIActionSheet to do this - sheet = [[UIActionSheet alloc] initWithTitle:@"Switch Setting" delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:@"Done", nil]; theSwitch = [[UISwitch alloc] init]; [sheet addSubview:theSwitch]; [sheet showInView:self.view]; - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { if (buttonIndex == actionSheet.firstOtherButtonIndex) { theSwitch .on? NSLog(@"Switch is on") : NSLog(@"Switch if off"); } } All this works great. I have problem with positioning. Unfortunately, I don't have a screen shot at the moment to post here. But the switch appears at the very top on the same line with the Action Sheet title and then below that is the Done button. Please someone help me how to position the switch below the Title and increase the Action Sheet size so it looks neat. I need this asap. Thanks.

    Read the article

1 2  | Next Page >