Could anyone please help me. When I zoom an image button changes its position. Do not know how to heal it.. I assume that might be because they are under "ScrollView" but when I add buttons to "View" they don't respond, they only respond in "ScrollView".
*.h
#interface ViewController : UIViewController <UIImagePickerControllerDelegate, UINavigationControllerDelegate, UIScrollViewDelegate> {
UIImageView *imageView;
UIButton *addImageBtn;
}
#property (nonatomic, retain) IBOutlet UIButton *addImageBtn;
*.m
#synthesize addImageBtn;
Thanks in advance!
Do you really need the buttons inside the scroll? Is autolayout on ? Attach the buttons to the bottom of the container view and put it outside the scroll
Related
I am trying to write my first hello world in xcode. I have two labels and two buttons in my view, and my AppDelegate.h file is like this:
#interface QuizAppDelegate : NSObject <UIApplicationDelegate>
{
int currentQuestionIndex;
// The model objects
NSMutableArray *questions;
NSMutableArray *answers;
// The view objects
IBOutlet UILabel *questionField;
IBOutlet UILabel *answerField;
}
#property (nonatomic, retain) IBOutlet UIWindow *window;
- (IBAction)showQuestion:(id)sender;
- (IBAction)showAnswer:(id)sender;
#end
Now i am trying to add reference to my label. I go to LaunchScreen.xib and right click on the label. According to the tutorial, i have to see "answerField" and "questionField" under the "Outlets" tab, but nothing shows up. Can anyone tell me why this can be happening?
Thanks
A few things:
1) That code should really be in a view controller and not the application delegate
2) You probably should be looking in the Main.storyboard file and not LaunchScreen.xib
3) Make sure that File's Owner is set to the correct view controller on Main.storyboard after you move that code into a view controller.
#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 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.
I have a view controller and I want part of it to be a UIView which I would put custom UIViews that I've created in and change them throughout the run of the app.
I have my view controller and in the storyboard I put in it a UIView.
I created a custom UIView that has a MKMapView:
#interface MapUIView : UIView <CLLocationManagerDelegate,MKMapViewDelegate> {
CLLocationManager *locationManager;
}
#property (weak, nonatomic) IBOutlet MKMapView *mapCtl;
#property (strong, nonatomic) IBOutlet UILabel *address;
#property (nonatomic,strong) CLGeocoder *reverseGeo;
#end
Now what I want to do is to set the UIView in the main view controller to my custom UIView and that it will show a MKMapView.
I'm kind of new to this, so if you see anything wrong with my implementation please correct me.
Select the view, then select the identity inspector in the utilities panel on the right-hand side. You can change it to be a custom subclass of UIView there.
Note that simply creating a MKMapView property on the view doesn't actually create an instance of MKMapView or add it as a subview, so you'll need to either do that programmatically or by adding it in the storyboard.