Using storyboard i want to add UITextview in the UIScrollview and the scroll the TextView in the in the screen. please help me...
scroller.contentSize=CGSizeMake(320,846);
[scroller setScrollEnabled:YES];
int GetIndex = [GetSelectedIndex intValue];
label = [firstheading objectAtIndex:GetIndex];
labelheading.text=label;
textviews = [firstdesc objectAtIndex:GetIndex];
textview.text=textviews;
[scroller addSubview:textview];
NSLog(#"textview:%#",textview);
NSLog(#"image:%#",getimage);
Just a suggestion, you could try adding a UIView on your ViewController first.
Then drag the UIScrollView into your UIView.
Then drag a UITextView into that.
I have this arrangement in a Storyboard - because I have an image in the top level UIView as well as the UIScrollView
Related
I have a UITableViewController with a UIView before the table view. The UIView (IBOutlet UIView *templateDescriptionView) has a UITextView (IBOutlet UITextView *templateDescription) in it. It looks like this:
The UITextView can have a variable amount of text. I'm trying to programmatically resize the UITextView and UIView to compensate for this, but it's not working as expected.
-(void) viewDidLoad
{
[templateDescription sizeToFit];
CGRect frame = templateDescription.frame;
frame.size.height = templateDescription.contentSize.height;
templateDescription.frame = frame;
CGRect viewFrame = templateDescriptionView.frame;
viewFrame.size.height = templateDescription.contentSize.height + 40; // 40 for padding
templateDescriptionView.frame = viewFrame;
}
The problem is, when everything renders, the UIView is partially on top of the UITableView. It resizes, but it's not resizing to the proper height. What am I doing wrong? This is Xcode 5, iOS7.
I am afraid I misunderstood your meaning. But UITableViewController is used to control a UITableView. Does it run well that a UITableViewController control a UIView? Maybe you put a UIView into the HeaderInSection of tableView. In iOS7, self.automaticallyAdjustsScrollViewInsets = NO; can be used to remove the space inset in scrollview.
I have the following code in viewDidLoad on my ViewController:
self.navigationController.navigationBar.tintColor = [UIColor colorWithRed:204.0/255 green:00.0/255 blue:00.0/255 alpha:1];
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"background.png"]];
autoNameLabel.text = (NSString *)[vendorDetails objectForKey:#"autoname"];
homeLabel.text = (NSString *)[vendorDetails objectForKey:#"homelab"];
descriptionTextView.text = (NSString *)[vendorDetails objectForKey:#"description"];
This all fits perfectly on the view. I know need to add an additional textView on the bottom so need the user to be able to scroll to see it. How can I add this info to a scrollable view and add my additional textView?
you could have your UIViewController extend UISCrollViewController. Or you could add a UIScrollView to your view controller's view in the method viewDidLoad. Then add all subviews of your view to the scrollview instead.
self.scrollView = [[UIScrollView all] initWithFrame:self.view.bounds]
self.scrollView.contentSize = CGSizeMake(self.scrollView.bounds.width, HEIGHT_OF_SCROLLABLE_AREA).
I would also do something like this for the scroll view height if your last textview is named lastTextView
HEIGHT_OF_SCROLLABLE_AREA = CGRectGetMaxY(lastTextView.frame + bottomPadding)
Are you sure you dragged all the other views on the scrollview? Make sure the contentSize of the scrollview is high enough(you know, higher than the screen) to scroll.
have u set delegate of UIScrollView. if you have not set delegate of UIScrollView then also it may possible that your scroll is not working.
I have a UIView, and I want to add an another UIView as a subView to it.
This is what I have done:
- (IBAction)showVerification:(id)sender {
[self.viewM addSubview: self.verificationView];
[self.labelVerification setText:offerId];
}
And this is the result:
Can You help me? Is it impossible to add a UIView to another in .xib file?
You can do it programmatically :
UIView* view2 = [[UIView alloc]initWithFrame:CGRectMake(30, 100, 1024-30, 768-110)];
[self.view addSubView:view2];
See my images i have done same and nothing is moved in it
Two views
After combining them just drag and drop it in side the view
And in Simulator
You can do as Wolvorin suggested or set an outlet for that leftview then add it into view on button event
I am new to iPad developer,
I made one Registration form in my application, when i see my application in Portrait mode,
i am able to see whole form with no scrolling, but when i see same form in Landscape mode, i am not able to see part which is at bottom of page, for that a scrolling should be there to see bottom part.
:
In my .h file when i replace
#interface ReminderPage : UIViewController{
...
...
}
:UIViewController with :UIScrollView
and then when i add label in my .m file like this,
UILabel *Lastpaidlbl = [[[UILabel alloc] initWithFrame:CGRectMake(70 ,400, 130, 50)]autorelease];
Lastpaidlbl.backgroundColor = [UIColor greenColor];
Lastpaidlbl.font=[UIFont systemFontOfSize:20];
Lastpaidlbl.text = #"Lastpaid on :";
[self.view addSubview:Lastpaidlbl];
I am getting error on last line Property view not found on object of type classname.
i am unable to add label in my view.
Any help will be appreciated.
The question appears to be really asking how can all the components on the screen be placed inside a UIScrollView, rather than a UIView. Using Xcode 4.6.3, I found I could achieve this by simply:
In Interface Builder, select all the sub-views inside the main UIView.
Choose Xcode menu item "Editor | Embed In | Scroll View".
The end result was a new scroll view embedded in the existing main UIView, will all the former sub-views of the UIView now as sub-views of the UIScrollView, with the same positioning.
If you want to replace your UIViewController with a UIScrollView, you will have to go a bit of refactoring to your code. The error you get is just an example of that:
the syntax:
[self.view addSubview:Lastpaidlbl];
is correct if self is a UIViewController; since you changed it to be UIScrollView, you should now do:
[self addSubview:Lastpaidlbl];
You will have quite a few changes like this one to make to your code and will face some issues.
Another approach would be this:
instantiate a UIScrollView (not derive from it);
add your UIView (such as you have defined it) to the scroll view;
define the contentSize of the scroll view so to include the whole UIView you have.
The scroll view acts as a container for your existing view (you add your controls to the scroll view, then add the scroll view to self.view); this way, you could integrate it within your existing controller:
1. UIScrollView* scrollView = <alloc/init>
2. [self.view addSubview:scrollView]; (in your controller)
3. [scrollView addSubview:<label>]; (for all of your labels and fields).
4. scrollView.contentSize = xxx;
I think the latter approach will be much easier.
Please put all of your UIComponents to the UIScrollview and then it will start scrolling.
please look in to content size. please change it according to the orientation of device.
You're subclassing UIScrollView, so there is no self.view because already self is the view (of the scrollview). You dont need to subclass the scrollview, you can just embed your components in a ivar scrollview and set its contentSize (in your case, you have to enable the scrolling just when the device is in landscape mode). In interface builder you can embed the selected elements in one click, Editor-> Embed in-> scrollview.
First create scrollview
UIScrollView * scr=[[UIScrollView alloc] initWithFrame:CGRectMake(10, 70, 756, 1000)];
scr.backgroundColor=[UIColor clearColor];
[ self.view addSubview:scr];
second
change [self.view addSubview:Lastpaidlbl];
to
[scr addSubview:Lastpaidlbl];
third
set height depends on content
UIView *view = nil;
NSArray *subviews = [scr subviews];
CGFloat curXLoc = 0;
for (view in subviews)
{
CGRect frame = view.frame;
curXLoc += (frame.size.height);
}
// set the content size so it can be scrollable
[scr setContentSize:CGSizeMake(756, curXLoc)];
Finally
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Override to allow orientations other than the default portrait orientation.
if (interfaceOrientation==UIInterfaceOrientationLandscapeLeft || interfaceOrientation==UIInterfaceOrientationLandscapeRight) {
self.scr.frame = CGRectMake(0, 0, 703,768);
} else {
self.scr.frame = CGRectMake(0, 0, 768, 1024);
}
return YES;
}
I'm with a project in which I have a UIScrollView inside a UIView. Inside the UIScrollView has to see a list of buttons in 3 columns and X rows. I have the code that displays the buttons, but does not inserted into the UIScrollView, it prints over and does not scroll. Besides this, also cover the TabBar I have in the bottom of the view.
The code of the function that displais the buttons is
for (int y_axis=0; y_axis<=3; y_axis++)
{
for (int x_axis=0; x_axis<=2; x_axis++)
{
UIButton *btn=[[UIButton alloc] initWithFrame:CGRectMake(16+100*x_axis,100.0+115*y_axis,88.0 ,88.0)];
btn.backgroundColor=[UIColor brownColor];
[self.view addSubview:btn];
}
}
How can I do to display this in the UIScrollView? Thanks!!
Assuming you have a UIScrollView scroller, you have to change your last line to this;
[self.scroller addSubview:btn];
If not, you are adding it to the view, and not the scroller. Also, you have to change the scrollers contentsize, which is the X*Y if how much it contains. For it to contain the whole screen and nothing more;
[self.scroller setContentSize:CGSizeMake(320, 480)]
^ ^
Replace that with the width and the height you want to scroll. Each time you add a button below your new buttons, you should update the contentsize.
It's because you are adding buttons on view [self.view addSubview:btn]; not on ScrollView. Try to make a view with all you buttons. and set your view with buttons as contentview of your scrollview .
first you need the UIScrollViewDelegate in your .h file and then also check buttons are subview of yourScrollView or not also you add this button in your scrollview with code like this bellow...
[yourScrollView addSubview:yourbuttonname];
after that in your viewDidLoad method declare contentsize of your scrollview like this...
yourScrollView.contentSize=CGSizeMake(320, anyheight);///here define height which you want to scroll the view...
hope this help you....
:)
Try these steps:
for loop
{
create buttons along with the desired frames;
add those buttons to scrollview;
}
set the content size of the scrollview according to no of rows;
add the scroll view to main view i.e. self.view;