It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I have requirement to add many button large size but its not coming within view bound what should i implement .
You can do it like this,
First in xib file add scrollview in your main view and than get another view in your screen which have large size dont add it to your main view but create different panel near it and than connect both scrollview and large contentview in .h file like this,
First in xib file
In .h file connect both contentView and scrollView,
#property (strong, nonatomic) IBOutlet UIView *contentView;
#property (strong, nonatomic) IBOutlet UIScrollView *scrollview;
Than in .m file add contentView to scrollView and make scrollview size to fit contentView,
- (void)viewDidLoad
{
[super viewDidLoad];
[scrollview addSubview:self.contentView];
scrollview.contentSize = self.contentView.frame.size;
}
You should use scrollview and then add those button in that scrollview. ScrollView is used when you have to use controls whose size is greater then your screen size.
You can increase its content size.
Hope it helps you.
Related
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
How do you disable tableview scrolling but enable cells to scroll within the section similar to how path for iPad does their friend and and notification cells, they are collapsable but the cells under the section only scroll within the section as in the section does not move to the top of the device but remains in its position.
There is no such controls available in iOS.
Possibly it is a customized UITableView. According to your description, each section of that table will contain another UITableView not simple UITableViewCell. That's why it have the feature you specified.
I had seen some open-source controls with similar feature, but forgot the name of those controls.
Your question is too broad, its better if you can add more details. But I will give you a rough answer to my understanding of your problem. What you can do is use UITextView in side your tableview cell and depending on the scenarion you can disable the scroll. It is recommended you keep only one scroll view scrollable at one time. UITableView is also inherits from UIScrollView. You can set the scroll disabling to your gesture handle methods or in a expanded cell scenario. To set scroll disable you can set scrollEnabled property to no.
Refer to http://developer.apple.com/library/ios/#documentation/uikit/reference/UIScrollView_Class/Reference/UIScrollView.html#//apple_ref/occ/cl/UIScrollView
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
A UIImageView object is in UIView.
UIImageView *foreview = //
UIView* backview = //
/* some preccess */
[backview addSubView:foreview];
Thus foreview is backview's subview.
I am going to resize and rotate the backview so that don't out of foreview.
How to code?
You can set superview.clipsToBounds=YES so that it will clip the subviews which goes out of bounds.
subviews will rotate with superview automatically.
if you don't want foreview rotate with backView, you shouldn't add it as subview.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I'm programmatically adding UIButtons to my view and I want to reposition them based on the orientation change.
I'm creating buttons by running 2 for loops for rows and cols and within the second for loop:
I'm assigning some properties and unique tags for each button. (Ex. Best way to build 10x10 grid of UIButtons?)
I'm detecting orientation change by listening to willAnimateRotationToInterfaceOrientation and was hoping to call buttons by based on their tag to move them to a new position.
I need to keep the state of the buttons so I can't remove them. It has to be repositioned.
Any suggestions? Thanks.
There are three ways to do this.
1) Using Autoresizing masks: Using this approach you need not do anything and the buttons automatically reposition based on the autoresizing masks set for the button with respect to its superview.
2) Second approach is to reposition the button after the rotation of the super view. You can write a method to calculate the new frame for the button based on the new width and height of its super view after rotation. There are rotation callbacks like
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
3) You can also implement below method in button's superview and reset the frames of your button
- (void)layoutSubviews
Hope this helps.
Use this:
UIButton *button = (UIButton *)[self.view viewWithTag:1]; // change viewWithTag to your buttons tag number. Now you can use button to position it anyway you want.
button.frame = CGRectMake(x, y, w, h); // x, y, width, height
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I am new to iOS programming, so I hope its not a stupid question to ask. I have to add ten different buttons in my view programmatically. I know how to add buttons programmatically, but my buttons won't fit within the view so some of them have to be present below the viewable height of the view, so I want to add the buttons such that the user can slide upward and downward to move across the view. How can this be done?
There are a number of standard UI elements UIKit provides that help handle displaying more content than the screen can display at any one time:
UICollectionView
UIScrollView
UITableView
You may benefit from some of the automatic layout and formatting provided by the UICollectionView but from your description it sounds as though either the UIScrollView or UITableView would be best suited for your scenario.
UIScrollView
The UIScrollView acts as the user's viewport into the underlying view it contains and provides complex panning and zooming functionality by default. It is highly configurable and you can prevent zooming functionality if you do not need it.
Just make sure to place your view inside the UIScrollView within Interface Builder and set the contentSize property. Setting a contentSize larger than the bounds of UIScrollView should enable scrolling automatically. To enable zooming have your UIViewController implement the UIScrollViewDelegate:
#interface MYViewController : UIViewController <UIScrollViewDelegate>
#end
Then ensure to return your view in the viewForZoomingInScrollView: method:
-(UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
return theViewContainingTheButtons;
}
UITableView
The UITableView is specifically designed to display a list of items that can be vertically scrolled if its content is taller than the size of the view.
A UITableView is composed of a number of UITableViewCells, each of which could contain one of the buttons you wish to display. Apple's Table View Programming Guide for iOS covers most aspects of the UITableView.
Conclusion
The UITableView approach focuses specifically on what you have asked and neglects that there may be other content in the view hosting the buttons. It also means that you would have to change your existing dynamic button placement code and write new code to work with table views. In reality it's likely that the UIScrollView is what your looking for but I wanted to provide exposure to other UI elements you may not have been aware of that could be used to achieve what you have described.
Good luck!
You need t use a special element, called a UIScrollView. It will handle all this automatically. Here's a link to the docs:
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIScrollView_Class/Reference/UIScrollView.html
You can use the UIScrollView.
Instead of adding UIButton to UIView addd then to UIScrollView and set UIScrollView contentSize.
Fore more help : UIScrollView from Apple.
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?