Database Reference
In-Depth Information
On to the Implementation
Next, we add an instance variable for the UIImagePickerController . Your @implementation line
should now look like this:
@implementation CloseFriendDetailViewController {
UIImagePickerController *_picker;
}
View Configuration Methods
We now add three methods to configure our view:
-(void)disableAllFields {
[_txtFirstName setEnabled:NO];
[_txtLastName setEnabled:NO];
[_txtBirthday setEnabled:NO];
for(UIGestureRecognizer *gesture in [_imgFriend gestureRecognizers]){
[_imgFriend removeGestureRecognizer:gesture];
}
}
-(void)enableAllFields {
[_txtFirstName setEnabled:YES];
[_txtLastName setEnabled:YES];
[_txtBirthday setEnabled:YES];
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self
action:@selector(photoTapped:)];
[_imgFriend addGestureRecognizer:tapGesture];
}
- (void)configureView {
_txtFirstName.text = [_closeFriend firstName];
_txtLastName.text = [_closeFriend lastName];
_txtBirthday.text = [_dateFormatter stringFromDate:[_closeFriend birthday]];
[_txtBirthday setInputView:[self setupDatePickerWithDate:[_closeFriend birthday]]];
[_txtBirthday setInputAccessoryView:[self setupKeyboardAccessoryView]];
_imgFriend.layer.borderColor = [UIColor darkGrayColor].CGColor;
_imgFriend.layer.borderWidth = 2.0f;
if([_closeFriend image] == nil)
_imgFriend.image = [UIImage imageNamed:@"ImgNoImage"];
else
_imgFriend.image = [UIImage imageWithData:[_closeFriend image]];
}
The first two methods are used to enable and disable the editing in the view. If we are in edit mode,
we will add a tap gesture to the image view that calls the photoTapped: method when the image view
is tapped. When we exit edit mode, we remove the tap gesture so that tapping has no effect.
 
Search WWH ::




Custom Search