Reputation: 33
I am trying to disable the user interaction to the view from one view. Below is my code.
DashboardViewControler.m
if([selectedTitle isEqual:@"VIEW"])
{
LatLongViewController * latview =[[LatLongViewController alloc]init];
latview.view.userInteractionEnabled = NO;
[self performSegueWithIdentifier:@"SWRevealViewController" sender:self];
}
In the latview
, I have UITextField
and UILabel
. I want to disable the user interaction while above scenario matches. Any help will be appreciated.
Upvotes: 0
Views: 612
Reputation: 19602
Assuming your UIViewController
owns the concerned views as properties:
yourTextfield.userInteractionEnabled = NO;
A beginners guide how to connect an view IBOutlet
from Storyboard
can be found here.
To disable user interaction for all subviews, iterate over them:
for (UIView *view in [self.view subviews]) {
view.userInteractionEnabled = NO;
}
Upvotes: 0
Reputation: 84
latview.view.userInteractionEnabled = NO;
You can't do it with IBOutlet
. All IBOutlet
are
operated by ViewController
. Here is my solution:
-Create new BOOL
in LatLongViewController.h file:
@property BOOL editMode;
-In DashboardViewControler.m
if([selectedTitle isEqual:@"VIEW"])
{
LatLongViewController * latview =[[LatLongViewController alloc]init];
latview.editMode = NO;
[self performSegueWithIdentifier:@"SWRevealViewController" sender:self];
}
-In LatLongViewController.m
- (void)viewDidLoad {
if(_editMode == NO){
view.userInteractionEnabled = NO;
}
}
I think you should use textfield.enable = NO;
if u have only one UITextField
in this view.
Upvotes: 2