I don't know if this is a bug or what but I can't understand why it happens.
I have 2 UITextField that once clicked show the users an UIPickerView, everything was working fine until I tried to add a custom arrow image in order to let the user know about the dropdown. this is the code I've used in order to create the rightView:
UIImageView *arrowDown = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"p-dropdown"]];
arrowDown.frame = CGRectMake(0, 0, 26, 22);
_province.rightViewMode = UITextFieldViewModeAlways;
_province.rightView = arrowDown;
_address.rightViewMode = UITextFieldViewModeAlways;
_address.rightView = arrowDown;
As soon as the last line ends the app freezes and it starts using like 20MB/s of RAM without stopping, I tried to comment all the code above and the problem doesn't occur, the funny thing is that if I comment just one of the two rightView ,so something like this:
UIImageView *arrowDown = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"p-dropdown"]];
arrowDown.frame = CGRectMake(0, 0, 26, 22);
_province.rightViewMode = UITextFieldViewModeAlways;
_province.rightView = arrowDown;
I can correctly see the rightView and the app doesn't freeze. Can someone help me to understand what is causing this weird issue?
One instance of UIView can't be utilized as right view of multiple UITextFields. You have to make two instances of your UIImageView to make your app work as expected. As you yourself found out, that one view cant be displayed on a screen multiple times simultaneously.
Related
My question is simple and I think it is possible but I cant find it.
My design is like this
I give corner radius to textview and also set textContainerInset for padding from right and left both side
txtview_msg.textContainerInset = UIEdgeInsetsMake(5, 10, 10, 5)
Now my problem is like for first 2 line and last 2 line my text goes beneath textview so I need some solution for it.
Please help me into this. Thank you
try this code
UIView *paddingView1 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, txtview_msg.frame.size.height - 30)];
txtview_msg.leftView = paddingView1;
txtview_msg.leftViewMode = UITextFieldViewModeAlways;
UIView *paddingView2 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, txtview_msg.frame.size.height - 30)];
txtview_msg.leftView = paddingView2;
txtview_msg.rightViewMode = UITextFieldViewModeAlways;
You can create at first a view of same size how much you given, put cornerRadius how much you given in textview now. than create textview viewSize - corner radius. place the textview exactly in middle of view. set the constraints from that view only, than it will work perfect how you want.
check this attached screenshot:
I am developing a products storage app and need to implement a UIStepper in it. The problem is that I just can't place it vertically as I would like to have it.
So does anyone know a way I can do this??
You should be able to modify the transform:
stepper.transform = CGAffineTransformMakeRotation(M_PI / 2.0);
Edit:
I now see that this is problematic for IB. I often create my views programmatically and this does not seem to be an issue:
UIStepper *stepper = [[UIStepper alloc] initWithFrame:CGRectMake(150, 150, 27, 94)];
// this doesn't even have a problem:
UIStepper *stepper = [[UIStepper alloc] init];
It only seems to be an issue with IB. Setting the frame after the fact also does not seem to help.
I have an app that has been working just fine for ages. I upgraded XCode and now 1 of my views is doing weird things.
None of the objects I attempt to add to the UIScrollview show up.
I have 2 screens that are basically identical in code (i literally copy and pasted). One of them works just fine, I click a button to move to the other screen, and it doesn't display ANY components I attempt to add to the scroll view.
Any ideas as to what could be wrong? Why it would suddenly stop adding components after upgrading Xcode?
I have a background image that I have tested and changed to self.view that changes just fine. But anything I try to add to my UIScrollView, nothing gets added. Some sample code...
my .h declaration
#interface OutgateInputViewController : UIViewController<UITextFieldDelegate,UIPickerViewDelegate>{
IBOutlet UIScrollView *outputsView;
a sample in my .m
UIGraphicsBeginImageContext(self.view.frame.size);
[[UIImage imageNamed:#"inputbackground.png"] drawInRect:self.view.bounds];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
self.view.backgroundColor = [UIColor colorWithPatternImage:image];
int x = 20;
int y = 20;
CGRect myImageRect = CGRectMake(0, 15, 320, 32.5);
UIImageView *myImage = [[UIImageView alloc] initWithFrame:myImageRect];
NSString *imgName = #"screen_logo.png";
[myImage setImage:[UIImage imageNamed:imgName]];
[outputsView addSubview:myImage];
y = y + 30;
pretty standard stuff. its an EXACT copy up to this point of the screen that works. (even a copy long after, i just pull data from a different location). So any ideas on what changed?
I went back and re-did everything from scratch, and apparently for some reason THIS View needs the additional __weak at the start of the declaration in the .h ...
no idea why as of yet, but this solved the issue of the entire view being broken.
__weak IBOutlet UIScrollView *outputsView;
I would like to know if there is any way to completely replace FBFriendPickerViewController's UITableView or modify the current one.
I need to reverse colors on the table ( white labels, black background) and I wasn't able to do that. So far, I was able to replace table's background but nothing else worked.
I tried something like:
self.myFriendPicker = [[FBFriendPickerViewController alloc] init];
self.myFriendPicker.delegate = self;
[self.myFriendPicker loadData];
[self.myFriendPicker clearSelection];
self.myFriendPicker.allowsMultipleSelection = NO;
self.myFriendPicker.view.frame = CGRectMake(30, 50, 250, 340);
And then I tried to create a new UITableView with red background to try it out and see if it works.
UITableView *tbView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, 100, 100) style:UITableViewStylePlain];
tbView.backgroundColor = [UIColor redColor];
self.myFriendPicker.tableView = tbView;
It didn't work and I would appreciate some suggestions.
Thanks for help.
I ended up implementing my own fabecookfriendpicker as a subview of uitableview.Displayinging the list of your friends is not a big issue but even though It is not a straightforward task since you need to lazy load the images and so on.
You have more opportunities to custumize the view with approach.But you can also try subclassing the FBFriendPickerViewController itself
In my UIViewController file, inside viewDidLoad method, i
CGRect gameArea = CGRectMake(30, 30, 100, 100);
UIImage *backgroundImage = [UIImage imageNamed:#"cards.png"];
UIImageView *myImageView = [[UIImageView alloc] initWithImage:backgroundImage];
UIView *topView = [[UIView alloc] initWithFrame:gameArea];
[topView addSubview:myImageView];
[[self view] addSubview:topView];
My expectation is that on top of existing view, a rectangle will show up with the image as his background.
Instead app crashes. What am i doing wrong?
It does not seem to matter where this code is pasted. I tried putting it as part of init - same thing happens. App crashes
The problem seems to happen here:
The stack trace looks as follows:
The problem is that my code runs as part of viewDidLoad method. By this time, things are established already.
Instead the same code works fine as part of the
- (void) viewWillAppear:(BOOL)animated
Hope this helps someone