In Signup page , I have many text fields in UIScrollVoew , so like other app i want to move Scroll upward once textfields at bottom are tapped , but i am not sure that old way which were using will work or not ? can any body please help what is best way of moving scroll automatically using autolayout
Use the custom class to autoScrolling click on last Textfield . Check it
You can define outlets in your code and set their sizes for your need. Something like this.
#property (weak, nonatomic) IBOutlet NSLayoutConstraint *textViewBottomConst;
self.textViewBottomConst.constant = height;
Related
Using Xcode5 and auto layout. Consider following scenario:
I have an outlet for "Dispatch" UITextField
#property (weak, nonatomic) IBOutlet UITextField *dispatchTextField;
If user clicks "Camera" button I want to hide dispatchTextField and move "Subject" and "Body"(below) up.
This is not a real scenario but I'm facing tasks where I will be using this kind of technique. I've seen code samples where container size can be modified and so on. In XAML - there is "StackPanel", in Android there is similar controls where I can just hide this TextField and views below automatically spring up.
So, what is the proper way to do this in XCode5 with auto-layout?
I tried (with no luck)
self.recipientTextField.hidden = YES;
I also tried
[self.recipientTextField setFrame:CGRectMake(0, 0, 0, 0)];
[self.view layoutIfNeeded];
Add a height constraint to the text field. After making sure there are no conflicting vertical constraints, add a reference to this constraint in your view controller.
Add an action to the Camera button and connect it to the view controller. Whenever the button is tapped, you would set the constant property of the height constraint to zero.
Make sure that other views are setup to have constant vertical spacing with the text field you wish to shrink.
I am trying to implement a mockup like this. However, I'm not sure which view controller I should be using for something like this? I tried UICollectionViewController but that puts cells of fixed width on each row. As you can see in my mockup, at some places I have a label taking all width and in other places I have three labels taking up the width.
You can use the simple UIViewController and drag the labels manually in the Storyboard. In order to make the rectangular label to round edged labels, you can create a IBOutletCollection of all those labels and iterate through the array, get each label's layer and set the corner radius to appropriate value.
e.g:
#property (strong, nonatomic) IBOutletCollection(UILabel) NSArray *customLabels;
As customLabels is an NSArray so it doesn't have a layer property. You can do it like this:
for (UILabel *label in customLabels) {
label.layer.cornerRadius = 5.0;
}
I'd stick with a plain UIViewController based controller.
The collection view is more for dynamic content like a bunch of photos. To do this with a collection view would take a bunch of unnecessary work.
With this layout, just lay the objects out manually on the storyboard and then you can just use the regular constraints if you need to resize dynamically and that will do just fine.
You can just use a UIViewController and set the buttons up appropriately in Interface Builder or programmatically.
If you take the latter approach, you can do something like this in your view controller
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
// be sure to do this step or you won't see your button
button.frame = CGRectMake(...);
// Customize your button here
[self.view addSubview:button
See this documentation for information on CGRectMake if you aren't familiar
Edit: I'm not sure if this approach will handle orientation changes appropriately. I suspect it would if you calculate the frame instead of hardcoding values. I don't have the ability to test that right now unfortunately.
Edit again: I didn't realize this was tagged for RubyMotion. I'm not familiar with that api so my code example may not be relevant.
This one is really bugging me! What is the name of this UIView subclass? I'm not talking about the compass itself, but the two dots at the bottom of the view. I know it's not a private API because I have seen it before. Or am I confused and this is not a UIView at all, but a UIViewController. Which UIView / UIViewController subclass is shown here. It acts like a UIScrollView, but has distinct pages, and has the dots at the bottom of the screen that show the users relative progress through the pages. I have checked this link about UIView subclasses, but became lost after about the 45th one. http://www.themusingsofalostprogrammer.com/2010/09/list-of-every-uiview-subclass.html
(source: tqn.com)
Thankyou for your time.
It is a UIPageControl. It corresponds (or is supposed to correspond) to the number of "pages" the user can scroll to, sideways. Normally, it indicates how many pages there are, and which one we are on, plus it typically provides a way to scroll sideways (by tapping to its left or right).
If I may add to what matt said...
To use a UIPageControl effectively, you also need a UIScrollView that contains the content. An update to the page control should result in a change to the contentOffset of the scrollView as shown in the code below. UIScrollView has a pagingEnabled property that should be set to YES to complete the illusion of paging.
- (IBAction)pageValueChanged:(UIPageControl *)sender
{
// self.pagedView is an IBOutlet to a UIScrollView
[self.pagedView setContentOffset:CGPointMake( sender.currentPage * 320, 0 ) animated:YES];
}
Quick question. Using IB, I have a subview in a ViewController. In that subview I have a label, which I would like to wire to my custom subview class. However, IB will not let me. What am I missing?
I also tried to add the label programmatically; however, it appears that the frame was not ever set. I could hard code the size of the label, but I could not make it dependent on the frame size of my subview, because the frame and the bounds were always zero rects, even after the view showed up in my view controller at a non zero size. Any ideas here would also be much appreciated.
You are actually completely right. It wont let you connect from IB to the Header of a custom view in Xcode 4.6.2
Personally I would file a Radar but I would want to do a bit more research to prove it and as this is a pattern I wouldn't ever use then I won't.
Fortunately you can get around it
Make sure your custom view is configured correctly in IB
and assuming you are setup something like this
Then you can manually declare in your header
#interface MyCustomView : UIView
#property (weak) IBOutlet UILabel *label;
#end
And drag FROM the dot that appears beside the property TO the label.
Or drag FROM the right-click HUD of the custom view TO the label.
Neither case will work by dragging from the label to the view.
In your header file, you need to define the label as an IBOutlet, then you can drag from your file's owner to the label.
IBOutlet * lblSomeLabel;
Disable AutoLayOut and try again.
so i was making a scroll view in my app so i can have more content showing in one view. the storyboard has a lot of text, 1 picture, and 3 buttons at the end. every time i scroll all the way to the button and click on one of them it takes me to the corresponding storyboard but than when i click the button to go back to the main storyboard with all the content, it doesn't led me scroll back to the top. this is all the code in the .m file for the scroll view:
-(void)viewDidAppear:(BOOL)animated{
[myScroll setScrollEnabled:YES];
[myScroll setContentSize:CGSizeMake(320, 940)];
}
this is the code in the .h file for the scroll view:
#interface SimplifyingNumericlaExpressionsViewController : UIViewController
#property (strong, nonatomic) IBOutlet UIScrollView *myScroll;
#end
is there any way i coud set the default coordinates of the scroll view of when it is being view? or something that can fox that?
herei s the link of a video showing the problem http://youtu.be/TgTaiEEhPhc
any idea or example counts. im a beginner :(
thanks!
UPDATE
i tried putting the same code i had in the viewDidLoad and this is what happen:
http://youtu.be/R6M4gGyLxgQ
im now having a different problem, it doesn't scroll all the way down and even though i tried changing the values it still doesn't work. any help? thanks!
the things you are doing should be done in viewDidLoad not viewDidAppear. I would assume the bug is comming from the fact your scroll view was super low already when you set the content size possibly reanchoring your scrollView lower?