I am stuck in a very strange problem. A default text field in iOS 8 & 7 behave very strange.
If the text box got focused the alignment of text get changed check the screen shots.
even with very small text size
Edit:
#import <UIKit/UIKit.h>
#interface LoginForm : UIViewController
#property (weak, nonatomic) IBOutlet UITextField *txt_username;
#property (weak, nonatomic) IBOutlet UITextField *txt_password;
- (IBAction)loginButtonPressed:(id)sender;
#end
Try this. Its more of a work around, not exactly getting to the root of the problem but make your VC a UITextFieldDelegate, then make it the textFields delegate and use the following code. -
(void)textFieldDidBeginEditing:(UITextField *)textField
{
// Change the alignment if you need to.
textField.textAlignment = NSTextAlignmentCenter;
}
It should be a alignment issue. In your storyboard check the UITextField Alignment matches with the below image.
Related
I have checked thoroughly for a solution to this (notably here: Can't connect IBOutlet in Interface Builder) but cannot see the solution. I have a UITextView that I am using as a text area in a form. I have connected it to this class member in IB:
IBOutlet UITextView *notes;
here is my .h
#import <UIKit/UIKit.h>
#import <AddressBookUI/AddressBookUI.h>
#interface U2MIDetailController : UIViewController <UITextFieldDelegate, UITextViewDelegate> {
IBOutlet UIButton *confirmButton;
IBOutlet UITextView *notes;
}
#property (nonatomic, retain) IBOutlet UITextView* notes;
#property ABRecordRef personObject;
#property (strong, nonatomic) IBOutlet UIScrollView *scroller;
#end
and my .m, the relevant bits:
#synthesize notes;
- (void)viewDidLoad
{
[super viewDidLoad];
//set up delegates for keyboard hiding
notes.delegate = self;
notes.text = #"Notes";
...
}
In the links I've found some have solved this issue by checking the File's Owner "Class" attribute on the Identity inspector. How do I do that? I have attached a pic of the hierarchy which looks correct to me, the identity inspector doesn't jump out at me either as having any suspicious properties.
Here is a shot of the storyboard:
and here is how it looks int he simulator:
check your scrollview frame either it is fit to frame or not. put blackground color you know where you did mistake
#everybody
Hi guys!
I've not found out the solution to my problem, so I decide to ask the question again.
First attempt is there LINK
I have screen w/ a few labels. Each of them might be from 1 to a dozen lines. So some times all content not to fit on screen so scrolling is necessary.
All seem to be easy and there are a lot of tutorials how to do it. Just set contentSize bigger than frame. But my problem that scrolling works only when I zoom in screen. Setting contentSize doesn't give any effect.
#interface OMSScroolViewController : UIViewController <UIScrollViewDelegate>
#property (strong, nonatomic) IBOutlet UIScrollView *scroll;
#property (strong, nonatomic) IBOutlet UILabel *label1;
#property (strong, nonatomic) IBOutlet UILabel *label2;
#end
and implementation
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
scroll.minimumZoomScale=1.0;
scroll.maximumZoomScale=1.0;
[scroll setContentSize:CGSizeMake(320, 1690)]; // constants for simplicity
scroll.delegate=self;
}
I've also tried to use a extra UIView inside UIScroolView but w/o any success.
Moreover I found a few threads there on stackoverflow w/ the same problem, unfortunately w/o solutions.
Thanks for cooperation.
I have screen w/ a few labels. Each of them might be from 1 to a dozen lines.
So some times all content not to fit on screen so scrolling is necessary.
All seem to be easy and there are a lot of tutorials how to do it.
But my problem that scrolling works only when I zoom in screen. Setting "contentSize" doesn't give any effect.
#interface OMSScroolViewController : UIViewController <UIScrollViewDelegate>
#property (strong, nonatomic) IBOutlet UIScrollView *scroll;
#property (strong, nonatomic) IBOutlet UILabel *label1;
#property (strong, nonatomic) IBOutlet UILabel *label2;
#end
and implementation
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
scroll.minimumZoomScale=1.0;
scroll.maximumZoomScale=1.0;
[scroll setContentSize:CGSizeMake(320, 1690)]; // constants for simplicity
scroll.delegate=self;
}
any suggestions?
thanks in advance.
Although not technically required, I've never had UIScrollView to work properly without using a content view to wrap the scrollable content. Once you wrap all your labels in a single view, your code should work without issue.
I am quite new to Xcode and I am having trouble placing the value of a slider in a label when the slider is value is changed.
Here is my code:
Header file:
#interface ViewTwoViewController : UIViewController
{
IBOutlet UISlider *slider;
IBOutlet UILabel *sliderLabel;
}
-(IBAction)sliderValue:(id)sender;
and here is my m file:
-(IBAction)sliderValue:(UISlider *)sender {
sliderLabel.text = [NSString stringWithFormat:#"%g", slider.value];
}
I am not 100% sure why the value isn't updating?
I am looking forward to hearing from you all!
Here's an XCode project that does what you're looking for: http://clrk.it/013r203C1y1F
Note that:
The label and slider are hooked up to the UIViewController as
IBOutlets in the storyboard.
The slider's valueChanged: method is linked to the UIViewController in the storyboard.
The slider's value is displayed using %f.
Your method would look something like this:
-(IBAction)sliderValueChanged:(id)sender
{
if (sender == _slider) {
_label.text = [NSString stringWithFormat:#"%0.3f", _slider.value];
}
}
Here would be my process to figure out the root cause of this problem.
Did you remember to connect the slider and sliderLabel outlets?
Did you remember to connect the IBAction to the slider? Set a breakpoint. When you drag the slider, does sliderValue: get called? What are the values of slider and sliderLabel?
Its unusual that your IBOutlets are not properties. I would expect to see:
#property (weak, nonatomic) IBOutlet UISlider *slider; and
#property (weak, nonatomic) IBOutlet UILabel *sliderLabel;
I tried your code and seems to be correct..Please check these things:-
1) Have you connected Slider action Value Changed to IBAction method for proper functioning.
2) Check our connections with Outlets.
Hope helps you out..
I have a little problem that my buttons doesn't move when I am using a code that should move the button.
ViewControlle.h:
#property (strong, nonatomic) IBOutlet UIButton *button1;
#property (strong, nonatomic) IBOutlet UIButton *button2;
ViewController.m:
#implementation GameViewController
#synthesize button1,button2;
code which should move the buttons:
button1.center=CGPointMake(button1.center.x, button1.center.y-10);
button2.center=CGPointMake(button2.center.x, button2.center.y+10);
why does the code not work or am I doing something wrong?
Because autolayout did not happen before view did load it will reset your locations.
when - (void)viewDidLayoutSubviews gets called its done so place your code here.
If you are using AutoLayout for ViewController than It's not work.
Uncheck the AutoLayout for ViewController.