Center UIPickerView Text

– (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view { UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 300, 37)]; label.text = [NSString stringWithFormat:@”something here”]; label.textAlignment = NSTextAlignmentCenter; //Changed to NS as UI is deprecated. label.backgroundColor = [UIColor clearColor]; [label autorelease]; return label; } or something like this.

How to steal touches from UIScrollView?

Sometimes you have to ask the question before you can find the answer. Dan Ray had a similar problem and solved it with a very different solution. – (UIView*)hitTest:(CGPoint)point withEvent:(UIEvent *)event { UIView* result = [super hitTest:point withEvent:event]; if ([result.superview isKindOfClass:[UIPickerView class]]) { self.scrollEnabled = NO; } else { self.scrollEnabled = YES; } return result; … Read more

UIPicker detect tap on currently selected row

First, conform the class to the UIGestureRecognizerDelegate protocol Then, in the view setup: UITapGestureRecognizer *tapToSelect = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tappedToSelectRow:)]; tapToSelect.delegate = self; [self.pickerView addGestureRecognizer:tapToSelect]; And elsewhere: #pragma mark – Actions – (IBAction)tappedToSelectRow:(UITapGestureRecognizer *)tapRecognizer { if (tapRecognizer.state == UIGestureRecognizerStateEnded) { CGFloat rowHeight = [self.pickerView rowSizeForComponent:0].height; CGRect selectedRowFrame = CGRectInset(self.pickerView.bounds, 0.0, (CGRectGetHeight(self.pickerView.frame) – rowHeight) / 2.0 ); … Read more

Source type 1 not available

This is because you are opening a camera on the simulator(or on a device not having camera)… since the code is something like [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera] and obviously, the simulator doesn’t have a camera… Proceed giving an alert like this, if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) { UIAlertView *myAlertView = [[UIAlertView alloc] initWithTitle:@”Error” message:@”Device has no camera.” delegate:nil cancelButtonTitle:@”OK” … Read more

Add UIPickerView in UIActionSheet from IOS 8 not working

Per the Apple docs, Important: UIActionSheet is deprecated in iOS 8. (Note that UIActionSheetDelegate is also deprecated.) To create and manage action sheets in iOS 8 and later, instead use UIAlertController with a preferredStyle of UIAlertControllerStyleActionSheet. Link to documentation for UIAlertController For example: UIAlertController * searchActionSheet=[UIAlertController alertControllerWithTitle:@”” message:@”” preferredStyle:UIAlertControllerStyleActionSheet]; [ searchActionSheet.view setBounds:CGRectMake(7, 180, self.view.frame.size.width, 470)]; … Read more

How to change the Font size in UIPickerView?

You need to implement pickerView:viewForRow:forComponent:reusingView: method in picker’s delegate – (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view{ UILabel* tView = (UILabel*)view; if (!tView){ tView = [[UILabel alloc] init]; // Setup label properties – frame, font, colors etc … } // Fill the label text here … return tView; }

How do I reload/refresh the UIPickerView (with new data array) based on button press?

You will have to implement the datasource and the delegate. once you press a button, set an array pointer to the appropriate array. than call [thePicker reloadAllComponents]; -(IBAction) usButtonPressed:(id)sender{ self.inputArray = self.usArray; [self.thePicker reloadAllComponents]; } -(IBAction) mexicoButtonPressed:(id)sender{ self.inputArray = self.mexicoArray; [self.thePicker reloadAllComponents]; } the datasource methods: – (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView { return 1; } – (NSInteger)pickerView:(UIPickerView … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)