I have setup the the content area for UIScrollView
in NIB file but i can see it no more scrollable.
Asked
Active
Viewed 524 times
-5

MUHAMMAD WASIM
- 191
- 2
- 11
2 Answers
4
When you add some view programmatically, you must add in your code (programmatically), a good place to add a UIButton is in the viewDidLoad methods in your implementation (.m) file, here an example:
- (void)viewDidLoad
{
[super viewDidLoad];
// other code...
UIButton *newButton = [[UIButton alloc] initWithFrame:CGRectMake(50, 50, 40, 40)];
[newButton setTitle:@"ProButton" forState:UIControlStateNormal];
// more properties you can configurate. See Apple doc
[newButton addTarget:self action:@selector(methodToFire:) forControlEvents:UIControlEventTouchUpInside];
// more action you can configurate for event...
[self.view addSubview:newButton];
// more code...
}

Onik IV
- 5,007
- 2
- 18
- 23
2
Try to this code:
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self
action:@selector(buttonClickMethod:)
forControlEvents:UIControlEventTouchUpInside];
[button setTitle:@"Button Title" forState:UIControlStateNormal];
button.frame = CGRectMake(50.0, 100.0, 160.0, 40.0);
[view addSubview:button];

Kanhaiya
- 249
- 1
- 2
- 8