May be it will a stupid for someone but i need the solution of this problem.I want to add a view controller on another view controller.If I explain it then,
- My main view controller is containing a uitableview.
- My another view controller containing a scrollview of buttons.
Now I want to set my scrollview controller at the top of the my main view controller [which is taking uitableview]. Thats mean [mainview addsubview:scrollview controller]
NOTE THAT: My scrollview is a view controller which is taking scrollview of some buttons.
If somebody give any example or source code or link of tutorial on these problem then it will very much helpful for me.
Thanks In advance.
EDIT:
Till now i have done…
In .h file
#import "scrollViewButtons.h"
scrollViewButtons *scrollButtonView;
@property (nonatomic,retain) scrollViewButtons *scrollButtonView;
In .m file
@synthesize scrollButtonView;
In viewDidLoad
scrollButtonView = [[scrollViewButtons alloc] initWithNibName:@"scrollViewButtons" bundle:nil];
CGRect frame = CGRectMake(0, 0, 320, 43);
scrollButtonView.view.frame = frame;
scrollButtonView.view.userInteractionEnabled =YES;
[self.view addSubview:scrollButtonView.view];
Now i can see the scrollButtonView in my main view but i can not find any user interaction.I can not scroll the scrollview of buttons.Can anybody tell me why i am not being able to interact with that scrollButtonView?
You are confusing views with view controllers. Apparently you have two views that have separate view controllers and you and you want these views to appear inside another view. That’s very easy to do.
If you have a view controller, such as firstVC, then you can add the view that it controls by adding that view to another view, such as bigView. just use
If you have a second view controller, such as secondVC, then you can add the view that it controls by adding that view to the another view, bigView. just use
Now you only need to manage the view bigView with a view controller.
You can vary this, depending on your level of understanding and the level of complexity or simplification you want to have. Most view controllers managed several UIViews — like labels, buttons, text fields, and other views. However, you may instantiate a second view controller (secondVC) inside the first view controller (firstVC) and then add the view of secondVC into the view of firstVC, like this:
I hope that helps.